Welcome to WebmasterWorld Guest from 54.144.124.152

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

     

compose

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

10+ Year Member



Hello,

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?

Thanks.

jdMorgan

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

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



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.

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month