I need an advice on how to modify the below htaccess
rule.
RewriteCond %{THE_REQUEST} /search-results\.php\?vtype=(apple|orange)&vcategory=([^&\s]+) [NC]
RewriteRule ^ /search-results/%1/%2? [NC,L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search-results/(apple|orange)/([^/]*)/$ /search-results.php?vtype=$1&vcategory=$2 [L]
The rule currently makes some urls to look better. For example instead of this:
www.website.com/search-results.php?vtype=apple&vcategory=fruit
I have this one: www.website.com/search-results/apple/fruit/
What I need to do is to have the same rule work with another parameter like search-results1
. So this url:
www.website.com/search-results.php?vtype=apple&vcategory=fruit
will look like this: www.website.com/search-results1/apple/fruit/
I tried the following but it does not work:
RewriteCond %{THE_REQUEST} /search-results\.php\?vtype=(apple|orange)&vcategory=([^&\s]+) [NC]
RewriteRule ^ /(search-results|search-results1)/%1/%2? [NC,L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(search-results|search-results1)/(apple|orange)/([^/]*)/$ /search-results.php?vtype=$1&vcategory=$2 [L]
Any idea why the above does not work and what modification I should do?
Thank you!