Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewriting & redirecting directory name

12:05 am on Feb 7, 2006 (gmt 0)

10+ Year Member

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?

12:18 am on Feb 7, 2006 (gmt 0)

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

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.


5:04 pm on Feb 7, 2006 (gmt 0)

10+ Year Member

Awesome - thanks!

Featured Threads

Hot Threads This Week

Hot Threads This Month