jez*_*mck 8 .htaccess mod-rewrite subdirectory
我为一个看似重复的问题道歉,但我看过的几十个问题实际上都没有同样的问题.
我有以下目录结构:
/.htaccess
/index.php
/subfolder/.htaccess
/subfolder/index.php
Run Code Online (Sandbox Code Playgroud)
我想要处理所有页面请求/index.php,除非请求开始,/subfolder在哪种情况下应该由它处理/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]
Run Code Online (Sandbox Code Playgroud)
/subfolder/.htaccess
RewriteBase /admin/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /admin/index.php?u=$1 [NC,QSA]
Run Code Online (Sandbox Code Playgroud)
anu*_*ava 11
你的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,QSA,L]
Run Code Online (Sandbox Code Playgroud)
对于这个简单的要求,管理文件夹中不需要.htaccess.