Friendly link with query

Discuss practical ways rearrange URLs using mod_rewrite.

Friendly link with query

Postby marcus1060 » Mon Jun 09, 2008 3:14 am

I want to make it so my friendly links will work, and I can add a regular query on to the back of them.
So the link would be like: /page/something?test=yay

And mod_rewrite would be:
RewriteRule ^page/(.*)\?(.*)$ index.php?page=$1&$2

I thought that'd work, however it does not.

Any help?
Thanks!
marcus1060
 
Posts: 2
Joined: Mon Jun 09, 2008 3:10 am

Postby richardk » Mon Jun 09, 2008 1:05 pm

The QSA (Query String Append) flag passes on the query string.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^page/([^/]+)/?$ /index.php?page=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby marcus1060 » Mon Jun 09, 2008 1:10 pm

Awesome, works like a charm thanks!
marcus1060
 
Posts: 2
Joined: Mon Jun 09, 2008 3:10 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 96 guests

cron