Changing SE friendly URL to index.php?a=1&b=2

Discuss practical ways rearrange URLs using mod_rewrite.

Changing SE friendly URL to index.php?a=1&b=2

Postby i8ramin » Fri Oct 15, 2004 3:19 pm

I want to use SE friendly urls throughout my site. I also dont want to use any file extensions for any of my pages.

So, for example I want the following rewrite:

/home --> /index.php?section=home
/home/options --> /index.php?section=home&p1=options
/home/options/colors --> /index.php?section=home&p1=options&p2=colors

Can this be achieved recursively with n number of paths? so each path after section would just map to p1, p2, p3, ..., pn

Most likely I wont have more than 2 paths after 'section', but I just wanted to know if it was possible.

I also dont want the above rule to apply to my /images, /styles and /scripts folders.
i8ramin
 
Posts: 1
Joined: Fri Oct 15, 2004 3:01 pm

Postby Caterham » Sat Dec 11, 2004 10:20 am

paste this code into your .htaccess file
Code: Select all
RewriteEngine On
RewriteRule ^(images|styles|scripts) - [L]
RewriteRule ^(.[^/]+)(/(.[^/]+)/(.[^/]+)/)?$ index.php?section=$1&p1=$3&p2=$4 [L]


Bob
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 33 guests

cron