Php Mod_重写隐藏目录
我对mod_重写规则没有什么意见。该规则似乎正在运行,但阻止了对目录及其文件的访问 这就是我想要完成的Php Mod_重写隐藏目录,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我对mod_重写规则没有什么意见。该规则似乎正在运行,但阻止了对目录及其文件的访问 这就是我想要完成的 www.example.com/about-us/ *** Parent rule www.example.com/about-us/our-mission.html *** child rule 虽然,我的规则是实现这一点,但阻止对服务器上的物理文件和目录的访问 在同一台服务器上,我有一个管理员界面,用户需要访问该界面才能进行更改 www.example.com/manage/dash
www.example.com/about-us/ *** Parent rule
www.example.com/about-us/our-mission.html *** child rule
虽然,我的规则是实现这一点,但阻止对服务器上的物理文件和目录的访问
在同一台服务器上,我有一个管理员界面,用户需要访问该界面才能进行更改
www.example.com/manage/dash.php
当我试图访问目录/管理或其is文件时,我被重定向到404页面,该页面是由子重写规则生成的重定向页面
当我注释掉子重写规则时,我可以访问上面提到的这些规则,但是使用子规则,访问被阻止
请参阅下面我的重写代码,并帮助我确定问题
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This rule will rewrite url to the main page www.example.com/about-us
RewriteRule ^([^/]+)/?$ index.php?get_parent=$1 [L]
#This rule will rewrite url to the secondary url www.example.com/abou-us/our-mission.html
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?get_parent=$1&get_child=$2 [L]
谢谢。您还需要将文件/目录从第二次重写规则中排除
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This rule will rewrite url to the main page www.example.com/about-us
RewriteRule ^([^/]+)/?$ index.php?get_parent=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This rule will rewrite url to the secondary url www.example.com/abou-us/our-mission.html
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?get_parent=$1&get_child=$2 [L]
这似乎很公平,因为您的url www.example.com/manage/dash.php与regexp匹配。在第一条规则末尾有[L]时,第二条规则不再使用这两个条件 您也应该添加一个不匹配的模式,请参见 这里我们假设/manage/dash.php文件确实存在
希望它能对您有所帮助。我明白了,所以这确实解决了问题,一旦规则结束,第一组排除将被消除。我没想过这样。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d