2010-07-10 135 views

回答

25
RewriteCond %{REQUEST_URI} foobar 
RewriteRule .* index.php 

some variant thereof

+0

感谢您的快速响应。完美的作品,但只是意识到而不是重写我需要它重定向。这可能吗? – Lee 2010-07-10 18:35:19

+0

得到它感谢 - 添加[R] – Lee 2010-07-10 18:39:12

1
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^/foobar/i$ index.php [NE,L] 
11
RewriteRule ^(.*)foobar(.*)$ http://www.example.com/index.php [L,R=301] 

(您的网站内没有足够的空间)

1

如果网址中包含certen字符串,重定向到index.php文件。您需要与%{REQUEST_URI}变量进行匹配,以检查url是否包含certen字符串。

重定向example.com/foo/bar的index.php如果URI包含酒吧在URI字符串的任何地方,你可以使用这个:

RewriteEngine on 

RewriteCond %{REQUEST_URI} bar 
RewriteRule^/index.php [L,R] 
相关问题