网站结构:
site/client
site/client/index.php
site/client/.htaccess
site/server
site/server/main.php
site/.htaccess
site / .htaccess指令:
Options -Indexes
DirectoryIndex disabled
RewriteEngine On
RewriteCond %{SERVER_NAME}%{REQUEST_URI} ^127.0.0.1/site(/.*)
RewriteRule ^ client%1 [END]
site / client / .htaccess指令:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^action= [OR]
RewriteCond %{QUERY_STRING} &action=
RewriteRule ^ ../server/main.php [END]
RewriteRule ^ index.php [END]
然后我点击链接http://127.0.0.1/site/
我收到错误403(禁止访问)。
Apache错误日志的一部分:
[rewrite:trace3] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] strip per-dir prefix: C:/Users/Public/xampp/htdocs/site/ ->
[rewrite:trace3] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] applying pattern '^' to uri ''
[rewrite:trace4] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] RewriteCond: input='127.0.0.1/site/' pattern='^127.0.0.1/site(/.*)' => matched
[rewrite:trace2] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] rewrite '' -> 'client/'
[rewrite:trace3] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] add per-dir prefix: client/ -> C:/Users/Public/xampp/htdocs/site/client/
[rewrite:trace8] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] Rule has END flag, no further rewriting for this request
[rewrite:trace2] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] strip document_root prefix: C:/Users/Public/xampp/htdocs/site/client/ -> /site/client/
[rewrite:trace1] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98c5240/initial] [perdir C:/Users/Public/xampp/htdocs/site/] internal redirect with /site/client/ [INTERNAL REDIRECT]
[rewrite:trace8] [pid 16152:tid 1952] mod_rewrite.c(482): [client 127.0.0.1:53242] 127.0.0.1 - - [127.0.0.1/sid#3ceff50][rid#98b6ef8/initial/redir#1] [perdir C:/Users/Public/xampp/htdocs/site/client/] Declining, no further rewriting due to END flag
[autoindex:error] [pid 16152:tid 1952] [client 127.0.0.1:53242] AH01276: Cannot serve directory C:/Users/Public/xampp/htdocs/site/client/: No matching DirectoryIndex () found, and server-generated directory index forbidden by Options directive
问题
为什么根文件夹处理成功,但是子文件夹有[autoindex:error]?
我需要处理没有索引文件但文件名为.htaccess的文件夹。
评论
此外,如果在客户端文件夹中将目录索引设置为“ index.php”,则重定向将成功。因此,[END]标志不会影响客户端文件夹中mod_rewrite的操作。
请
所有这些条件对于在彼此之间创建嵌套站点都是必要的,在那里将存在没有索引文件的文件夹,但是将.htaccess文件作为站点的根文件夹。