Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Apply 301 redirect to all links of old dir to new dir

Want to rename a directory

11:08 am on May 23, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 3, 2005
votes: 0


I am trying to rename my existing forum directory to some other name but afraid that all incoming links to existing forum will be treated as 404, so thought mod rewrite will work in this case to mark 301 redirect for all old links to new forum link.

I have use this htaccess code to redirect all links of old forum to new one
RewriteEngine on
RewriteBase /
Redirect permanent /old_forum_directory [site.com...]

It works, now when some one try to browse old forum it redirect user to index page of new forum, but issue is now when i click on any thread link of old forum it redirect me to index page of new forum instead of particular thread in new forum.

Can any one tell me how to achieve this?


3:31 pm on May 23, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

1) The Redirect directive is NOT handled by mod_rewrite [httpd.apache.org]. It is a mod_alias [httpd.apache.org] directive. So you're mixing directives from two different modules here.

2) Without example URLs, this problem is hard to diagnose. I assume that your forum uses query strings to select the proper thread, and the query strings may be getting dropped by mod_alias. Perhaps this code, using mod_rewrite, might work better:

RewriteEngine on
RewriteRule ^old_forum_directory/(.*)$ http://www.site.com/new_forum_directory/$1 [R=301,L]

mod_rewrite will pass query strings through without changing them, unless you take steps in the code to change them.

I assume this code is going into your root .htaccess file. If it goes in a server config file, add a leading slash to the RewriteRule pattern.

"RewriteBase /" is not needed. That is the default configuration, and need not be specified.



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members