Chattr & CHMOD Needed For My htaccess File?

  • altom55
  • Novice
  • Novice
  • altom55
  • Posts: 24
  • Loc: UK

Post 3+ Months Ago

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
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4923
  • Loc: NY

Post 3+ Months Ago

chmod 700 .htaccess should do it.
  • altom55
  • Novice
  • Novice
  • altom55
  • Posts: 24
  • Loc: UK

Post 3+ Months Ago

Thanks Web Master, I'll try that for a while & see how it goes
  • altom55
  • Novice
  • Novice
  • altom55
  • Posts: 24
  • Loc: UK

Post 3+ Months Ago

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
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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!
  • altom55
  • Novice
  • Novice
  • altom55
  • Posts: 24
  • Loc: UK

Post 3+ Months Ago

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
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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
  • altom55
  • Novice
  • Novice
  • altom55
  • Posts: 24
  • Loc: UK

Post 3+ Months Ago

Thanks for your help
Regards Alan.....

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 100 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.