Mod rewrite mod_rewrite将以字符串开头的URL重定向到google

Mod rewrite mod_rewrite将以字符串开头的URL重定向到google,mod-rewrite,apache2,Mod Rewrite,Apache2,我试图建立一个简单的重写规则,但我似乎无法让它工作。基本上,我想将任何以“餐馆”开头的地址发送到某个地方,并将所有其他地址发送到我的引导程序 修订规则^食肆 重写规则^/餐厅索引.php 这就是我目前所拥有的。 即 mysite.com/restaurants mysite.com/restaurants/blabla mysite.com/restaurants/beep/boop 所有请求都将转到google,所有其他请求都将转到index.php。如果您想在.htaccess文件中使用

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

修订规则^食肆 重写规则^/餐厅索引.php

这就是我目前所拥有的。 即

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

所有请求都将转到google,所有其他请求都将转到index.php。如果您想在.htaccess文件中使用规则,则必须删除模式中的前导
/

RewriteRule ^restaurants http://example.com/
RewriteRule !^index\.php$ index.php

这里有一套应该有效的规则

RewriteRule ^/resturants.*   http://www.google.com/ [L] 
RewriteRule !^/index\.php$   index.php
您需要指定google重定向为last(L),否则它将被第二条规则覆盖