Use htaccess To Redirect All Traffic To One Directory To A New URL
Posted by alex in Insights at 10:53 PMTonight we are launching a new portiong of Question-Defense.com called Engage. This new section allows anyone to write questions and allows the community to respond to those questions. Now people can become more involved and more questions will be answered because the possibilities of who can respond are endless.
During this launch we are removing the QD Forums since they were never used much anyway. The new Engage format allows the community to interact in a much easier way. So since the forums did have some content and the search engines had the links to that content in their cache we needed to forward all requests to the forums directory to the new QD Engage site.
The htaccess Redirection Goal:
The old forums directory was actually /community with links structured similar to /community?wpforumaction=viewforum&f=3.0 or similar. The new Engage site has been launched on a new sub domain which is http://engage.question-defense.com . The overall goal is to take any traffic destined for /community and community/$ and redirect to the new Engage URL. Below is the .htaccess RewriteRule we used to accomplish our goal.
.htaccess RewriteRule To Redirect All Traffic From One Directory To A New URL:
RewriteRule ^community(.*)$ http://engage.question-defense.com/ [L,R=301]
If you don’t have any other .htaccess rewrite rules then you need to turn on the RewriteEngine. Below would be an example of using .htaccess only for the redirection of one directory.
.htaccess Rewrite All Traffic To One Directory To a New URL:
RewriteEngine On RewriteBase / RewriteRule ^community(.*)$ http://engage.question-defense.com/ [L,R=301]
As you can see the above will redirect any traffic destined for /community to http://engage.question-defense.com.
- .htaccess Redirect All Traffic to www There are a couple things that need to be considered...
- LiteSpeed Web Server: Redirect All Web Traffic to HTTPS Except One Directory Or URL LiteSpeed web server uses the same Rewrite engine that Apache...
- Use .htaccess To Redirect One Domain To Another Domain I have been using a WordPress plugin for awhile called...
- How To Redirect All Litespeed HTTP Traffic To HTTPS The below explains the steps necessary to redirect all Litespeed...
- Simple SEO URL: Request Exeeded The Limit Of 10 Internal Redirects I was hired to install some ZenCart plugins recently one...
Tags: .htaccess, apache, directory, Engage, redirect, rewrite, RewriteEngine, RewriteRule, traffic, URL


























Entries (RSS)
hi it seems this page redirects your original referrer what do you think
[Reply]
alex Reply:
February 4th, 2010 at 9:41 PM
Hello z2gt,
Not sure what you mean.
Thanks.
alex
[Reply]
Can this redirect all pages in that directory to the new location?
For example I have over 50k pages under “forums” on my domain which I now want to move under “forum”. Can I use the rule like
RewriteRule ^forums(.*)$ forum/ [L,R=301]
[Reply]
alex Reply:
June 9th, 2010 at 10:18 AM
Hello chodhry,
If you want all 50K pages to redirect to the new forums homepage the RewriteRule in the article will work. If you want the forum URL structure to be maintained then it needs to be modified to work.
Thanks.
alex
[Reply]