rewrite cond and rule.

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
geethalakshmi
Forum Commoner
Posts: 31
Joined: Thu Apr 24, 2008 10:38 pm

rewrite cond and rule.

Post by geethalakshmi »

Hi,

I don't know much about rewrite cond and rule.

I have several categories that are dynamically set so the url looks similar to,

Code: Select all

 
Code:
http://www.example.com/fold/index.php?rid=1
http://www.example.com/fold/index.php?rid=2
 
 
But what I want is urls that look like:
Code:
http://www.example.com/fold/ss page
http://www.example.com/fold/tt page
 
Regards,
geetha
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Re: rewrite cond and rule.

Post by gurjit »

create a .htaccess file in your root folder with the following rewrite rule:

Code: Select all

 
RewriteBase /
RewriteEngine on
 
RewriteRule ^([0-9]+)/([a-zA-Z-]+)/([a-zA-Z-]+)/$ /fold/index.php?rid=$1 [L]
 
 
The href link will need the rid passed through, so the ([0-9]+) will be the rid. I have included this at the start of the folder structure, feel free to shift it around.

so your href links should be something like

2/fold/whatever/
User avatar
The_Anomaly
Forum Contributor
Posts: 196
Joined: Fri Aug 08, 2008 4:56 pm
Location: Tirana, Albania

Re: rewrite cond and rule.

Post by The_Anomaly »

I'm not sure what OS yo'ure using, or if you're having trouble setting up the rewrite on the server, but this link truly saved me with that. I spent hours trying to get it to work--and this fixed it. Just throwing that out there, in case you're having that problem.
Post Reply