文件:
/home/asite.com/httpdocs/dynamic-subdir/.htaccess
/home/asite.com/httpdocs/dynamic-subdir/index.php
想:
Find the desired directory. (dynamic-subdir)
所需目录为" dynamic-subdir"。
RewriteEngine On
#Forward
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . {dynamic-subdir}index.php$1 [L]
请求:
asite.com/dynamic-subdir/apage/asubpage/
定向页面:
asite.com/dynamic-subdir/index.php?apage/asubpage/
答案 0 :(得分:0)
尝试更改htaccess中的RewriteRule:
RewriteRule . {dynamic-subdir}index.php$1 [L]
到
RewriteRule ^(.*)$ index.php?$1 [L,R]
然后移除RewriteBase /
。然后,您可以将此.htaccess放在任何目录中,它会将 / dynamic-subdir / apage / asubpage / 重写为 /dynamic-subdir/index.php?apage/asubpage / 或将.htaccess放入的任何 dynamic-subdir 。
答案 1 :(得分:0)
请求:
asite.com/dynamic-subdir/apage/asubpage/
定向页面:
asite.com/dynamic-subdir/index.php?apage/asubpage/
规则应该是:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /([^/]+)/(.*) index.php?$2 [QSA,L]
请告诉我它是否有效;)