onestepcreative
onestepcreative

Reputation: 561

Redirect with htaccess unless search

I'm not sure if this is possible, but here's whats going on.

I currently have an .htaccess rule to redirect example.com to store.example.com

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

This works great, however my search queries no longer work. What I'd like to do is redirect example.com to store.example.com unless I'm searching.

A sample search would look like this:

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

Thank you in advanced for your help

Upvotes: 1

Views: 44

Answers (1)

Have you tried:

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

Upvotes: 2

Related Questions