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 / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

RewriteRule Help
catch a name and rename

 6:08 pm on Apr 9, 2009 (gmt 0)

Hello everyone,
I need to know if it is possible with the RewriteRule to catch a specific name in the url and rename with the new name.

For example:
To catch airagency and replaced it with airspace

www.domain.com/airagency/freedom.jsp or

new redirection

www.domain.com/airspace/freedon.jsp and




 6:14 pm on Apr 9, 2009 (gmt 0)

Rewrites do not 'make' URLs.

If you need a new URL, then use that new URL in the links in your pages.

It is links that 'define' URLs.


If the internal filename on the server is not changing, theh use a rewrite as that will connect the URL request used out on the web, with the actual filename used inside the server, without revealing what that filename actually is.


If you have a new URL to replace an old URL, then use a redirect to force requests for the old URL to make a new request for the new URL. However, you still need to use the new URL in the links in your pages, and no longer link to the old URLs.


 6:32 pm on Apr 9, 2009 (gmt 0)

Thank you so much for you're answer,

But the problems comes that my site has been online for a while and to avoid user that have a favorite of a page to have a 404 html error.

rules work well but I have many folder and file name with airagency that I would like to catch.

RewriteRule .*/airagency/(.*)$ /airspace/ [L,R=301]



 6:59 pm on Apr 9, 2009 (gmt 0)

That was pretty close. I'd suggest:

RewriteRule ^(([^/]+/)*)airagency([^A-Za-z].*)?$ http://www.example.com/$1airspace$3 [R=301,L]

The "bounding" subpatterns are meant to prevent this redirect from being invoked if anything but a slash precedes "airagency" or if any letter(s) directly follow "airagency" -- for example, "blah/newairagency/blah" will not be redirected.


Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / New To Web Development
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