mod_rewrite help

mod_rewrite help

Posted by: kentor
Posted on: 2006-08-19 16:26:00

hello, I'm trying to get pages like
http://www.rent-index.com/detailsCottages.php?postid=1493 to become
www.rent-index.com/1493 or at least www.rent-index.com/vacations/1493
I've tried reading this stuff on
http://wiki.dreamhost.com/index.php/Mod_rewrite but i can't figure out
how to do this.
Can you please help :)

Re: mod_rewrite help

Posted by: scjessey
Posted on: 2006-08-19 18:16:00

In reply to:

hello, I'm trying to get pages like
http://www.rent-index.com/detailsCottages.php?postid=1493 to become
www.rent-index.com/1493 or at least www.rent-index.com/vacations/1493


My knowledge of mod_rewrite is pretty limited, but I think this will work:

RewriteEngine On
RewriteRule ^vacations/([0-9-]+)/ /detailsCottages.php?postid=$1 [QSA]

Remember that mod_rewrite doesn't convert the old URL into the new URL. It does the opposite. If someone enters http://rent-index.com/vacations/1234/ it will be redirected to http://rent-index.com/detailsCottages.php?post=1234

Re: mod_rewrite help

Posted by: kentor
Posted on: 2006-08-20 10:39:00

hello, but instead of redirecting it, is it possible to make such a url www.rent-index.com/1321 in php ?



Re: mod_rewrite help

Posted by: kentor
Posted on: 2006-08-20 11:48:00

oh ic, it redirects it but the url stays the same :) thats what i want. thanx a lot for your help :)

Edited by kentor on 08/20/06 11:56 AM (server time).

Tags: indexdreamhostmodphphelpwikihttpreadingstuff