I need to rewrite a rule using htaccess, I currently have the following:
RewriteRule ^test/example/(.*)/(.*)/(.*)/example\.html$ test/example/example/index.php?s=$1&t=$2&p=$3 [L]
which rewites the url from:
test/example/example/index.php?s=Red&t=Audi&p=Petrol
to
test/example/Red/Audi/Petrol/example.html
and this works but I would like the rule to work for the following 3 conditions:
-
where no values are in the querystring so just goes to the url: test/example/example.html
-
where “s” in the querystring has a value and then rewrite rule sends user to: test/example/Red/example.html
and
- where all three vars have values and then the url goes to: test/example/Red/Audi/Petrol/example.html
Thanks
Add three rewrite rules in this order:
And all done.