I have a 2nd store which I'm closing and consolidating to my existing store. Instead of simply redirecting old links to a base directory I'd like to leave the customer looking at a search page result that best fits what they were trying to see on the store I'm closing.

For example, my current "old" store hosted on a separate subdomain looks like this:


However I'm trying to use htaccess to redirect to my main domain (www) and convert the "url-key" to use "+" instead of "-" so that we can use it as the "q" like the following:


For now I'm redirecting all of my traffic to the base domain which I think is bad for SEO and user experience.

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

I've tried all different combinations of htaccess redirects however I'm struggling to make it work correctly.

1 Answer 1


Below is the code that you should place in your .htaccess file on the old site:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
  RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
  • While I appreciate your attempt in helping your answer is not the correct solution. My original question was specific and it seems like you glanced over the details in an attempt to just get an "answer" under your belt. Again I appreciate you trying to help but your answer doesn't solve my issue. Jun 14, 2016 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.