I've made the following rule mainly for SEO.
My url can be one of the 8 options (all redirect same physical file indices_archive.php with different query_string):
- http://example.com/indices
- http://example.com/indices/
- http://example.com/indices/reviews
- http://example.com/indices/reviews/
- http://example.com/indices/reviews/1
- http://example.com/indices/reviews/1/
- http://example.com/indices/reviews/1/GTA
- http://example.com/indices/reviews/1/GTA/
The code I made to apply the rule:
- Code: Select all
RewriteRule ^indices/([^/\.]+)$ indices_archive.php?type=$1 [L]
RewriteRule ^indices/([^/\.]+)/$ indices_archive.php?type=$1 [L]
RewriteRule ^indices/([^/\.]+)/([^/\.]+)$ indices_archive.php?type=$1&page=$2 [L]
RewriteRule ^indices/([^/\.]+)/([^/\.]+)/$ indices_archive.php?type=$1&page=$2 [L]
RewriteRule ^indices/([^/\.]+)/([^/\.]+)/([^/\.]+)$ indices_archive.php?type=$1&page=$2&q=$3 [L]
RewriteRule ^indices/([^/\.]+)/([^/\.]+)/([^/\.]+)/$ indices_archive.php?type=$1&page=$2&q=$3 [L]
Tt works but seems inefficient and long for no reason, some of the fields are optional and including them in a different row seems wrong.
I'm trying to simplify my rule into less rows without any luck.
Thanks in advance,
Oleg