Reputation: 1237
I'm trying to hide my .htaccess file so everyone can't just read it out in their browser.
My .htaccess file is located here: http://businessgame.be/.htaccess as you can see you can still just read it out.
I tried adding the following:
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
and also
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>
But none of it seems to work. This is really weird. Am I doing anything wrong?
Upvotes: 3
Views: 8331
Reputation:
You just follow this sample code for .htaccess files...
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
ErrorDocument 404 /404.php
</IfModule>
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(yourwebsite.com)(:80)? [NC]
RewriteRule ^(.*) http://www.website.com/$1 [R=301,L]
DirectoryIndex index.php
order deny,allow
Header unset ETag
FileETag None
<FilesMatch "\.(jpg|png|gif|js|css|ico|swf)$">
Header set cache-Control: "max-age=572800, must-revalidate"
</FilesMatch>
This would more help for us.....
other wise it will help you...
<Files ~ "\.html$">
Order allow,deny
Deny from all
Satisfy All
</Files>
<Files ~ "\.css$">
Order allow,deny
Deny from all
Satisfy All
</Files>
Else its will working well.. i `ll checked this code in my website.
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Thank u....for giving opportunity post for you...
Upvotes: 6
Reputation: 515
This is my serv config, and it work, you should try the same :
# secure htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>
<FilesMatch "\.(htaccess|htpasswd)$">
Order Allow,Deny
Deny from all
</FilesMatch>
Upvotes: 4