我已經將mi站點文件移動到子文件夾並使用.htaccess重定向到它,但我需要拒絕直接訪問此文件夾或子文件夾。Mod重寫重定向文件夾爲root並使用文件夾作爲根
在.htaccess得到這個:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule^http://%1%{REQUEST_URI} [R=301,L]
# Block access to hidden files and directories.
# This includes directories used by version control systems such as Git and SVN.
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
# Deny direct access to this directory or any sub-directory
RewriteRule ^site/(.*)$/[R=301,NC,L]
# Do not apply redirection to these folders/files for compatibility
RewriteRule ^(subdir1|subdir2)(/|$) - [L,NC]
RewriteRule ^robots.txt - [L,NC]
# root from sub-directory
RewriteRule ^(.*)$ site/live/$1 [L,QSA]
</IfModule>
當我去:
htt://domain.com/site -> htt://domain.com (CORRECT REDIRECTING)
htt://domain.com/site/unexist-> htt://domain.com (CORRECT REDIRECTING)
htt://domain.com/site/live -> htt://domain.com/site/live/ (NOT REDIRECTING HERE!)
在現場/現場存在其他的.htaccess一些重寫規則。這可能是問題嗎?
<IfModule mod_rewrite.c>
RewriteRule ^about-us$ about.php
RewriteRule ^privacy$ privacy.php
RewriteRule ^oauth$ index.php
</IfModule>
DirectoryIndex index.php
# Custom error messages/pages
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
不'/網站/現場/'有其他的.htaccess? – anubhava 2014-09-23 16:14:39
@anubhava是的它確實,我已經更新了更多的細節問題 – 2014-09-23 16:20:59