Page 1 of 1

htaccess rewriterule

Posted: Tue Sep 13, 2011 3:22 am
by wihvd
I have URL like this:
site.com/fol1/fol2/?per1=Audi&per2=A4&type=2&per3=2009

How can I replace per1, per2, per3 to underscores?

Re: htaccess rewriterule

Posted: Tue Sep 13, 2011 12:18 pm
by phazorRise
As per thread title, i consider you want to do it with htaccess. So here little example -
[text]RewriteRule ^_/([A-Za-z0-9-]+)/_/([A-Za-z0-9-]+)/?$ page.php?per1=$1&per2=$2[/text]
put this in htaccess file.

and write urls something like -
[text]<a href="_/software/_/hardware">Your_link</a>[/text]

and while retrieving use -

Code: Select all

$per1=$_GET['per1'];
$per2=$_GET['per2'];
But though this does the job, why are using _ to be appeared in urls. Use something meaningful. Instead you should specify URL which user can easily understand.
Htaccess is meant to be used for writing human friendly urls.