执行.htaccess规则,文件夹中没有索引文件

时间:2019-06-07 10:45:38

标签: apache .htaccess mod-rewrite directoryindex

网站结构:

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。
  • 请勿禁用模块或编辑站点文件夹之外的其他文件。一世 无法访问。
  • 必须存在字符串“ DirectoryIndex disabled”。

所有这些条件对于在彼此之间创建嵌套站点都是必要的,在那里将存在没有索引文件的文件夹,但是将.htaccess文件作为站点的根文件夹。

0 个答案:

没有答案