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

Apache Web Server Forum

Rewriting & redirecting directory name

10+ Year Member

Msg#: 5526 posted 12:05 am on Feb 7, 2006 (gmt 0)

I want to rewrite and redirect users from

I've tried simple rewrite statements, RewriteCond %{REQUEST_URI} statements and RewriteCond %{THE_REQUEST} statements in various incarnations and can't seem to get any of them to work. The closest I've gotten is with this:
RewriteCond %{REQUEST_URI} /blue-widget/
RewriteRule ^(.*)$ http://www.example.com/purple-widget/$1 [R=301,L]

The result of the above is that /blue-widget/ gets appended to the end of the URL, so this:
becomes this:
And this:
becomes this:

I feel like I'm getting really close to a solution. Any help?



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

Msg#: 5526 posted 12:18 am on Feb 7, 2006 (gmt 0)

If the code goes into the top-level directory .htaccess file, then it's:

RewriteRule ^blue-wdget/(.*)$ http://www.example.com/purple-widget/$1 [R=301,L]

Or you can put this code into the .htaccess file in the /blue-widget subdirectory:

RewriteRule ^(.*)$ http://www.example.com/purple-widget/$1 [R=301,L]

The URLs 'seen' by RewriteRule are localized to the current directory, which accounts for the difference.



10+ Year Member

Msg#: 5526 posted 5:04 pm on Feb 7, 2006 (gmt 0)

Awesome - thanks!

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