My attempt:
RewriteCond %{QUERY_STRING} ^id=(.*)$ [NC]
RewriteRule ^/product$ /product/%1 [NC,L,R=301]
I want to apply this rule to /product/
and /supplier/
directories only. They are both first level sub directories.
Note: product/?id={xxx}
is actually product/index.php?id={xxx}
. Apache hides my extensions and indexes. Just want to point that out.
My product/index.php
handles the parameter given and determines what page it should show:
index.php
if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
//html for individual page e.g. /product/?id=foo
//e.g. <h1><?= $_GET['id'] ?> Page</h1>
} else {
//html for product list e.g. /product/ (no parameters)
}