Forum Moderators: phranque

Message Too Old, No Replies

Basic RewriteRule help needed

need to rewrite URLs on our site and I am lost :(

         

madpenguin

8:22 am on Jan 13, 2005 (gmt 0)

10+ Year Member



Hello everyone.. I have a quick htaccess rewrite question. I am a bit lost when it comes to rewrites and am in desperate need to fix a problem on the site. Can one of the gurus assist? hehe

Here's what I need to do... I need to rewrite this:

http://www.mysite.com/cms/?m=show&id=3242

into this:

http://www.mysite.com/?m=show&id=3242

Essentially removing the /cms directory from every URL on the site. The show&id=INTEGER is a variable that will change from article to article of course, so it would need to be dynamic. Currently the site is broken and I cannot get it to work to save my life! :( Can anyone assist? Thanks so much in advance...

Adam

Caterham

9:02 pm on Jan 13, 2005 (gmt 0)

10+ Year Member



You can use
RewriteRule ^cms/ / [QSA,L]

in a .htaccess in your doc root. This will rewrite every request starting with cms/ to the root (internal redirect). The query string gets append (QSA-Flag).

For a forced external redirect use the flag [R=301,QSA,L]

Robert

[edited by: jdMorgan at 12:01 am (utc) on Jan. 14, 2005]
[edit reason] Fixed code formatting problem [/edit]

jdMorgan

12:03 am on Jan 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should not need the [QSA] flag unless you wish to append additional parameters to the existing query string; Otherwise, the existing query is passed-through unchanged, even without [QSA].

Jim