0

我试图建立一个简单的重写规则,但我似乎无法让它工作。基本上我想将任何以“餐厅”开头的地址路由到某个地方,并将所有其他地址路由到我的引导程序。

RewriteRule ^/restaurants http://www.google.com RewriteRule !^/restaurants index.php

是我到目前为止所拥有的。IE。

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

都会去谷歌,所有其他请求都会去 index.php

4

2 回答 2

1

如果要在 .htaccess 文件中使用规则,则必须删除/模式中的前导:

RewriteRule ^restaurants http://example.com/
RewriteRule !^index\.php$ index.php
于 2009-02-19T15:18:02.247 回答
1

这是一组应该起作用的规则

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

您需要指定谷歌重定向是最后一个(L),否则它将被第二条规则覆盖。

于 2009-02-19T16:13:54.270 回答