Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I write a .htaccess mod_rewrite rule to redirect all traffic to a specific subfolder to a different subdomain, but include all the trailing URI and url structure and in a SEO friendly way.





share|improve this question

migrated from stackoverflow.com Jun 9 '11 at 19:35

This question came from our site for professional and enthusiast programmers.

up vote 3 down vote accepted

You can put this into the root's .htaccess:

RewriteEngine On
RewriteRule ^photogallery/(.*)$ http://photos.site.com/$1 [L,R=301,QSA]
share|improve this answer
Works great! thanks – Daniel S Jun 9 '11 at 18:47
I just killed a phpbb site and used this to redirect to a static html page. RewriteRule ^view* http://www.wsmcbbs.info/index.html [L,R=301,QSA] – Chris K Jan 3 '14 at 2:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.