php directory urls

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
ayfine
Forum Newbie
Posts: 22
Joined: Mon Nov 27, 2006 4:52 pm

php directory urls

Post by ayfine »

hey all,

in ruby on rails, I know it is very easy to instead of having index.php?article=251 you could just have index/article/251. How would you go about doing this in php to have search engine friendly urls?

thanks
LSJason
Forum Commoner
Posts: 45
Joined: Mon May 12, 2008 4:43 pm

Re: php directory urls

Post by LSJason »

Create a file called .htaccess in the directory in which index.php resides. Put this inside it:

Code: Select all

 
RewriteEngine On
RewriteRule index/(.*)/(.*) index.php?$1=$2
 
Should do the job.
Post Reply