我如何重写一个URL,当我输入重写的.htaccess到子目录
http://mydomain.com/index.php
相同
http://mydomain.com/subdomain/index.php
我如何重写一个URL,当我输入重写的.htaccess到子目录
http://mydomain.com/index.php
相同
http://mydomain.com/subdomain/index.php
如果你只是想处理index.php
那么下面的工作:
RewriteEngine On
RewriteRule ^(index\.php|)$ subdomain/$1 [L]
但是,如果要重定向每一个请求subdomain folder
那么下面的工作:
RewriteEngine On
RewriteRule ^(?!subdomain/).*$ subdomain%{REQUEST_URI} [L,NC]
这规则(它是如何写入的)会导致无尽的重定向... – LazyOne 2012-04-25 14:59:08
真的!这可能会更好... – PiTheNumber 2012-04-25 15:25:30
对于所有文件
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)$ /subdomain/$1 [NC]
相同:这个规则(如何写它现在)将导致无尽的重定向... – LazyOne 2012-04-25 14:59:35
第二条规则:你错过了第二个右括号 – LazyOne 2012-04-25 17:26:43
@LazyOne:非常感谢指出它,修复它现在。 – anubhava 2012-04-25 17:33:25