Santiago Santiago - 1 year ago 101
PHP Question

Categories and subcategories mod rewrite

i have this code as an example for a subcategory url,

the file is


The link to the url is like this:

<a href="store/subcategory.php?catid=guitars&subcatid=electrics"></a>

and the htaccess rule so far is

RewriteRule ^store/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ subcategory.php?catid=$1&subcatid=$2 [L]

As a result i want accomplish this,
Turn this url:


How can i do this? What am i missing?

Answer Source

You need an additional redirect rule:

RewriteEngine On

RewriteCond %{THE_REQUEST} /subcategory\.php\?catid=([^\s&]+)&subcatid=([^\s&]+) [NC]
RewriteRule ^ /store/%1/%2? [R=302,L,NE]

RewriteRule ^store/([\w-]+)/([\w-]+)/?$ subcategory.php?catid=$1&subcatid=$2 [L,QSA,NC]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download