2010-06-03 130 views
0

所有的意见在网上说事: 重写URL 301-A URL-B如何使用mod_rewrite从一个页面重定向到另一个页面?

但如果我打开mod_rewrite的,将无法正常工作与RewriteEngine叙述上

所以,我(似乎?)糟糕的正则表达式,但不应该在这里需要它。我该怎么办:

RewriteCond %{HTTP_HOST} ^untamed-adventures.com/travel/How/tabid/58/Default.aspx [NC] 

RewriteRule ^(.*)$ http://untamed-adventures.com/ [R=301,L] 

回答

0

%{HTTP_HOST}扩展到请求的主机,所以它永远不会匹配untamed-adventures.com/travel/How/tabid/58/Default.aspx,只有untamed-adventures.com

如果你要转发http://untamed-adventures.com/travel/How/tabid/58/Default.aspxhttp://untamed-adventures.com/,试试这个:

RewriteCond %{HTTP_HOST} =untamed-adventures.com 
RewriteRule ^/travel/How/tabid/58/Default.aspx$ http://untamed-adventures.com/ [R=301] 

L标志是多余的;前锋总是最后的。

+0

啊,RewriteRule位工作除了一个必须删除领导/ 非常多! – Dan 2010-06-07 06:03:41

+0

@Dan只有在.htaccess中或如果你设置了'RewriteBase /' – Artefacto 2010-06-07 06:18:13

+0

啊哈!是的,在.htaccess中。 – Dan 2010-06-07 07:41:59

0

一点也不清楚你想要做什么。 HTTP_HOST是请求的URL中的主机名部分,在这种情况下是“untamed-adventures.com”,因此RewriteCond永远不会匹配。

认为你试图做的是:

重定向301 /travel/How/tabid/58/Default.aspx http://untamed-adventures.com/

在这种情况下,不需要的mod_rewrite在所有。

+0

该文件中还有其他需要mod_rewrite的指令。 – Dan 2010-06-04 03:38:01

相关问题