1
votes

I need to convert these 3 URLs:

1 - Mydomain/view/index.php?make=toyota&model=runner&color=white

2 - Mydomain/view/index.php?make=toyota&model=runner

3 - Mydomain/view/index.php?make=toyota

Into these:

1 - Mydomain/toyota/runner/white

2 - Mydomain/toyota/runner

3 - Mydomain/toyota


So I used an online Mod Rewrite tool generator and got this for the FIRST url:

RewriteEngine On RewriteRule ^([^/])/([^/])/([^/]*)$ /view/index.php?make=$1&model=$2&color=$3 [L]

It worked perfect when I used the FIRST friently URL. Then I just copied and modified that RewriteRule twice and used them for the other two URLs, resulting into this:

RewriteEngine On

RewriteRule ^([^/])/([^/])/([^/]*)$ /view/index.php?make=$1&model=$2&color=$3 [L]

RewriteRule ^([^/])/([^/])$ /view/index.php?make=$1&model=$2 [L]

RewriteRule ^([^/]*)$ /view/index.php?make=$1 [L]


First friendly URL still works fine. Second and third URLs stops on 500 Internal Server Error.

Would somebody help? Thanks!

1

1 Answers

0
votes

You need to exclude the destination uri you are rewriting to. To fix the loop error ,add the following at top of your htaccess right after RewriteEngine on line

RewriteRule index\.php$ - [L]