2012-08-09 37 views
0

如果任何喜歡進來格式添加別名

http://localhost/index.php/bla... 

我想將其轉換爲http://localhost/er/index.php/bla...

我嘗試以下,但它似乎是在循環網址無限期

RewriteRule ^localhost/index/php/(.*)$ localhost/er/index.php/$1 [R=301,L] 
RedirectMatch 301 ^/localhost/index.php/(.*)$ localhost/er/index.php/$1 

回答

1

你有2件不同的事情在進行中,RewriteRule(mod_rewrite的)和一個RedirectMatch(mod_alias中)。你只需要一個,但這些都不能與主機名(本地主機)相匹配。如果必須只限於「localhost」的主機,那麼你需要做的是:

RewriteEngine On 
RewriteCond %{HTTP_HOST} localhost$ [NC] 
RewriteRule ^/?index\.php/(.*)$ /er/index.php/$1 [R=301,L] 

否則,你可以堅持用mod_alias中:

一切後 /index.php/
Redirect 301 /index.php/ /er/index.php/ 

將自動獲得追加。

+0

非常感謝你! – user391986 2012-08-10 17:36:18