Redirect traffic from a specific subfolder to a different domain with preserved path in .htaccess

Redirect traffic from a specific subfolder to a different domain with preserved path in .htaccess - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about seo, htaccess, 301-redirect, mod-rewrite, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


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.



ie.



www.example.com/photogallery/2010/January-Spring-Photos/


to



example.site/2010/January-Spring-Photos/

Solution :

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



RewriteEngine On
RewriteRule ^photogallery/(.*)$ http://photos.site.com/$1 [L,R=301,QSA]

Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect