homepage Welcome to WebmasterWorld Guest from 54.226.93.128
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Apply 301 redirect to all links of old dir to new dir
Want to rename a directory
compose




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

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




msg:3657462
 3:31 pm on May 23, 2008 (gmt 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.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved