我为一个看似重复的问题道歉,但我看过的几十个问题实际上都没有同样的问题.
我有以下目录结构:
/.htaccess /index.php /subfolder/.htaccess /subfolder/index.php
我希望所有页面请求都由/index.php处理,除非请求启动/子文件夹,在这种情况下它应由/subfolder/index.php处理
>例如/ abc被重写为/index.php?u=abc
>例如/ subfolder / def被重写为/subfolder/index.php?u=def
我已经绕过这个圈子了,所以任何帮助都将受到大力赞赏.
编辑:忘了提问题!
子文件夹中的请求由根index.php处理,而不是子文件夹. (/ subfolder请求除外)
当前文件内容
/.htaccess
Options -Indexes -MultiViews +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/admin RewriteRule ^(.*)$/index.php?u=$1 [NC,QSA]
/subfolder/.htaccess
RewriteBase /admin/ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$/admin/index.php?u=$1 [NC,QSA]
解决方法
你的root .htaccess是这样的:
Options -Indexes -MultiViews +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(?!admin/)(.+)$/index.php?u=$1 [NC,QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^admin/(.+)$/admin/index.php?u=$1 [NC,L]
对于这个简单的要求,管理文件夹中不需要.htaccess.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。