2013-03-03 41 views
1

我不确定这是否可能,但以下是发生了什么事情。使用htaccess重定向除非搜索

我现在有一个.htaccess规则重定向example.com store.example.com的

RewriteCond %{HTTP_HOST} example\.com [NC] 
RewriteCond %{REQUEST_URI} ^/$ 
Rewriterule ^(.*)$ http://store.example.com/[L,R=301] 

这个伟大的工程,但我的搜索查询不再起作用。除非我在搜索,否则我想要将example.com重定向到store.example.com。

样本搜索看起来像这样:

http://example.com/?s=my+search+query+string 

谢谢你在先进的帮助

回答

2

你试过:

RewriteCond %{HTTP_HOST} example\.com [NC] 
RewriteCond %{QUERY_STRING} ^!(s=(.*))$ 
Rewriterule ^(.*)$ http://store.example.com/ [L,R=301] 
+0

我不知道什么是完整的实现会看起来像这个RewriteCond。我尝试了几个不同的东西,但大多数都导致无限重定向循环。有任何想法吗? – onestepcreative 2013-03-03 09:00:27

+0

使用工作解决方案编辑。 – 2013-03-03 09:05:22

+0

这工作完美!谢谢! – onestepcreative 2013-03-03 09:09:57