我正在尝试隐藏我的.htaccess文件,以便每个人都无法在浏览器中阅读它。
我的.htaccess文件位于:http://businessgame.be/.htaccess 正如你所看到的,你仍然可以读出它。
我尝试添加以下内容:
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
以及
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>
但似乎没有任何效果。这真的很奇怪。我做错了吗?
答案 0 :(得分:4)
您只需按照.htaccess文件的示例代码...
<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>
这对我们更有帮助.....
另外,它会帮助你......
<Files ~ "\.html$">
Order allow,deny
Deny from all
Satisfy All
</Files>
<Files ~ "\.css$">
Order allow,deny
Deny from all
Satisfy All
</Files>
否则它的运行良好..我将在我的网站上查看此代码。
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]
谢谢你....为你提供机会信息......
答案 1 :(得分:1)
这是我的serv配置,它可以工作,你应该尝试相同:
# secure htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>
<FilesMatch "\.(htaccess|htpasswd)$">
Order Allow,Deny
Deny from all
</FilesMatch>