Rewrite request

New to mod_rewrite? This is a good place to start.

Rewrite request

Postby actd2009 » Sun May 03, 2009 6:23 am

Hello,

I have one URL and want to rewrite it:

Real URL:

http://localhost/index.php?mod=product&catid=1&sort=2

To:

http://localhost/product?catid=1&sort=2

Can someone help me?

Thanks!
actd2009
 
Posts: 2
Joined: Sun May 03, 2009 6:14 am

Postby actd2009 » Sun May 03, 2009 7:01 am

I found:

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{QUERY_STRING} ^([^=]+)=([^&]+)
RewriteRule ^all_products$ index.php?m=all_products&%1=%2 [NC,L]

Thanks all.
actd2009
 
Posts: 2
Joined: Sun May 03, 2009 6:14 am

Postby richardk » Sun May 03, 2009 9:39 am

You can use the QSA (Query String Append) flag instead
Code: Select all
Options +FollowSymlinks

RewriteEngine On

RewriteRule ^all_products$ /index.php?m=all_products&%1=%2 [NC,QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 12 guests

cron