假设我有以下文件/目录结构:
/.htaccess
/index.php
/module/.htaccess
/module/module.php
在/.htaccess
我有:
SetEnvIf Request_URI "^.*" HTTP_WTLIB_VERSION=5.2
RewriteCond %{REQUEST_URI} ^/REST/(.*)
RewriteRule ^REST/(.*)/(.*) /wtlib_%{ENV:HTTP_WTLIB_VERSION}/REST/$1/$2 [L,QSA]
在/module/.htaccess
我有:
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule .* /wtlib_%{ENV:HTTP_WTLIB_VERSION}/modules/post/admin/ [L,NC,QSA]
但它没有用。这实际上是可能的吗?
更新:
评论中有人问我应该提供全部细节。
实际的/.htaccess
文件内容为:
RewriteEngine on
Options +Indexes +FollowSymlinks -MultiViews
RewriteBase /
SetEnvIf Request_URI "^.*" HTTP_WTLIB_VERSION=5.2
#-------------------------------------------------------------------------------
RewriteCond %{REQUEST_URI} ^/REST/(.*)
RewriteRule ^REST/(.*)/(.*) /wtlib_%{ENV:HTTP_WTLIB_VERSION}/REST/$1/$2 [L,QSA]
#-------------------------------------------------------------------------------
DirectoryIndex index.php index.html
AddDefaultCharset UTF-8
AddType text/x-component .htc
#-------------------------------------------------------------------------------
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#-------------------------------------------------------------------------------
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin$ /admin/ [L]
#-------------------------------------------------------------------------------
RewriteCond %{REQUEST_URI} ^/admin/modules/(.*)/(.*)
RewriteRule ^ - [env=ActiveModuleName:%1]
RewriteRule ^admin/modules/(.*)/(.*)/(.*)/(.*)/(.*) /wtlib_%{ENV:HTTP_WTLIB_VERSION}/modules/$1/admin/$2/$3/$4/$5 [L,QSA]
RewriteRule ^admin/modules/(.*)/(.*)/(.*)/(.*) /wtlib_%{ENV:HTTP_WTLIB_VERSION}/modules/$1/admin/$2/$3/$4 [L,QSA]
RewriteRule ^admin/modules/(.*)/(.*)/(.*) /wtlib_%{ENV:HTTP_WTLIB_VERSION}/modules/$1/admin/$2/$3 [L,QSA]
RewriteRule ^admin/modules/(.*)/(.*) /wtlib_%{ENV:HTTP_WTLIB_VERSION}/modules/$1/admin/$2 [L,QSA]
RewriteRule ^admin/search /wtlib_%{ENV:HTTP_WTLIB_VERSION}/apps/admin/search.php [L,QSA]
RewriteRule ^admin/(.*)$ /wtlib_%{ENV:HTTP_WTLIB_VERSION}/apps/admin/$1 [L]
RewriteRule ^images/(.*)$ /wtlib_%{ENV:HTTP_WTLIB_VERSION}/images/$1 [L]
RewriteRule ^wtlib/(.*)$ /wtlib_%{ENV:HTTP_WTLIB_VERSION}/$1 [L,QSA]
#-------------------------------------------------------------------------------
RewriteRule ^ - [env=dd:%{REQUEST_URI}]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_URI} !(\.png|\.PNG|\.jpg|\.JPG|\.gif|\.GIF|\.jpeg|\.JPEG|\.bmp|\.js|\.css|\.htm|\.html|\.htc|\.ico)$
RewriteRule ^(.*)$ /index.php [T=application/x-httpd-php,L]
/module/.htaccess是:
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule .* /wtlib_%{ENV:HTTP_WTLIB_VERSION}/modules/post/admin/ [L,NC,QSA]