htaccess rewriterule

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wihvd
Forum Newbie
Posts: 6
Joined: Mon Mar 29, 2010 12:29 am

htaccess rewriterule

Post 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?
User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: htaccess rewriterule

Post 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.
Post Reply