Chattr & CHMOD Needed For My htaccess File?

  • altom55
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 16, 2011
  • Posts: 24
  • Loc: UK
  • Status: Offline

Post November 3rd, 2012, 7:59 am

Im having problems keeping my .htaccess file from changing & adding # & empty spaces.
This really screws up the menu & other chunks on my site

I use php includes on my site via the AddHandler code below in the htaccess file which enables me to include PHP includes in my HTML site. This is the part that keeps changing

Code: [ Select ]
RewriteEngine on
AddHandler application/x-httpd-php5 .html .htm .php
  1. RewriteEngine on
  2. AddHandler application/x-httpd-php5 .html .htm .php


Every week my site is a mess due to these changes in my htaccess file & I have to redo the code.

My host gives no explanation why the file keeps editing without my knowledge.
I contacted my host who says they can rectify this with the chattr command to keep the htaccess file from being edited behind my back.

I dont really understand this method much, but I have made my htaccess file readonly by removing users’ write permission. Will that be enough? Am I doing the right thing?

Regards Alan....






Code: [ Select ]
RewriteEngine on
AddHandler application/x-httpd-php5 .html .htm .php
  1. RewriteEngine on
  2. AddHandler application/x-httpd-php5 .html .htm .php
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 3rd, 2012, 7:59 am

  • Don2007
  • Web Master
  • Web Master
  • No Avatar
  • Joined: Nov 21, 2006
  • Posts: 4924
  • Loc: NY
  • Status: Offline

Post November 5th, 2012, 12:02 pm

chmod 700 .htaccess should do it.
How do you know when a politician is lying? His mouth is moving.
  • altom55
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 16, 2011
  • Posts: 24
  • Loc: UK
  • Status: Offline

Post November 5th, 2012, 2:23 pm

Thanks Web Master, I'll try that for a while & see how it goes
  • altom55
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 16, 2011
  • Posts: 24
  • Loc: UK
  • Status: Offline

Post November 5th, 2012, 2:35 pm

Ive just tried that and I could not see my site at all. I have now set it to 744
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post November 5th, 2012, 4:35 pm

chattr is a command in the Linux operating system that allows a user to set certain attributes on a file residing on an ext2-based filesystem. I have used this in the past which does prevent users including possibly the root user from changing it.

The -i argument / parameter is what sets the immutable bit which prevents the file from being erased or changed. So you would do something like

chattr +i .htaccess

That adds the immutable bit for that file and prevents the file from being changed. After you do that command, try and change the file, if its working correctly you won't be able to change it no matter what permissions you give it.

To undo that command you would use a minus sign instead of the plus sign so you would do:

chattr -i .htaccess

I hope that helps!
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • altom55
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 16, 2011
  • Posts: 24
  • Loc: UK
  • Status: Offline

Post November 5th, 2012, 4:49 pm

Thanks for your reply bigwebmaster.
Do I have to ask my host to do this for me? Im not sure (or confident enough) how I go about this, but if it stops my files editing 'themselves' then I may try it.
Is this a separate file that I add to my root?

Regards
Alan
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post November 5th, 2012, 7:29 pm

You would type that command via SSH. If you don't know how to login via SSH or if your web host does not provide you SSH access, then they may need to do it for you. You would simply change to the directory that your .htaccess file is located in and then type that command:

chattr +i .htaccess
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • altom55
  • Novice
  • Novice
  • No Avatar
  • Joined: Jan 16, 2011
  • Posts: 24
  • Loc: UK
  • Status: Offline

Post November 6th, 2012, 4:23 am

Thanks for your help
Regards Alan.....

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 174 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.