2009-02-19 80 views
-1

我試圖設置一個簡單的重寫規則,但我似乎無法讓它工作。基本上我想將任何以「餐館」開頭的地址發送到某個地方,並將所有其他地址發送到我的引導程序。mod_rewrite重定向以字符串開頭的網址到谷歌

重寫規則^ /餐廳http://www.google.com 重寫規則!^/index.php的餐館

是我到目前爲止所。 即。

  • mysite.com/restaurants
  • mysite.com/restaurants/blabla
  • mysite.com/restaurants/beep/boop

都會去谷歌,所有其他請求會去to index.php

回答

1

下面是一組規則,應該工作

RewriteRule ^/resturants.* http://www.google.com/ [L] 
RewriteRule !^/index\.php$ index.php 

你要指定,谷歌重定向是最後一個(L),否則會被第二條規則被覆蓋。

1

如果要使用.htaccess文件中的規則,則必須刪除模式中的前導/

RewriteRule ^restaurants http://example.com/ 
RewriteRule !^index\.php$ index.php 
相關問題