mod_rewrite with 2 parameters does not work

advertisements

I tried to use modrewrite but it does not work well. I wana change this url: /summoner/summoner.php?summonerName=HORNETDanny&region=euw to: /summoner/SummonerName/Region/

I dont now if this will work with modrewrite or if i need routing.

Thanks for help!


You have to treat the rules separately. All Conditions preceding rules only apply to a single rule. Following rules are not touched by that rule. You tried to 'chain' two rules. The second rule never could have matched, since the first one was a catch-all that changed the syntax. Apart from that you have to make sure that the first rule does not catch unwanted requests. Also think about whether you want to use the * or the + operator in the regexes. I suggest you use the + operator, so that you have a clear error message when empty values are requested for a 'page' or a 'subpage'.

So this might come closer to what you are looking for:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?p=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?p=$1&sp=$2 [L]