开发者

Mod_rewrite uses only some rules

I have this htaccess:

RewriteEngine On
RewriteRule ^tuote\.php/([^/]+) tuote.php?data=$1 [L]
RewriteRule ^ryhma\.php/([^/]+) ryhma.php?data=$1 [L]

RewriteRule ostoskori ostoskori.php [L]
RewriteRule ^lisaa\/([^/]+) ostoskori.php?a=4&data=$1 [L,NC]
RewriteRule ^lisaa-ostoskoriin/([^/]+) ostoskori.php?a=1&data=$1 [L,NC]
RewriteRule tyhjenna-ostoskori ostoskori.php?a=2

RewriteRule ^vahenna\/([^/]+) ostoskori.php?a=3&data=$1 [L,NC]
RewriteRule ^poista\/([^/]+) ostoskori.php?a=5&data=$1 [L,NC]

When I access lisaa-ostoskoriin, it doesn´t work and seems to connect ostoskori.php but it should connect ostoskori.php?a=1&data=$1.

When I access tyhjenna-ostoskori, it doesn´t either work and seems to connect ostoskori.php but it should ostoskori.php?a=2.

All others will work, but these are only that do not work. How should I modify the code to make it work better?

URL examples

http://somesite.com/tuote/1-Product-name --> tuote.php?data=1-Product-name http://somesite.com/ryhma/1-Category-name --> ryhma.php?data=1-Category-name http://som开发者_开发技巧esite.com/ostoskori --> ostoskori.php

http://somesite.com/lisaa/1-Product-name --> ostoskori.php?a=4&data=1-Product-name http://somesite.com/lisaa-ostoskoriin/1-Product-name --> ostoskori.php?a=1&data=1-Product-name


Try this:

RewriteEngine On
RewriteRule ^/(tuote|ryhma)\.php/([^/]+) $1.php?data=$2 [L]

RewriteRule ^/lisaa-ostoskoriin/([^/]+) ostoskori.php?a=1&data=$1 [L,NC]
RewriteRule ^/tyhjenna-ostoskori ostoskori.php?a=2 [L]
RewriteRule ^/vahenna/([^/]+) ostoskori.php?a=3&data=$1 [L,NC]
RewriteRule ^/lisaa/([^/]+) ostoskori.php?a=4&data=$1 [L,NC]
RewriteRule ^/poista/([^/]+) ostoskori.php?a=5&data=$1 [L,NC]

RewriteRule ^/ostoskori ostoskori.php [L]

I haven't tested it myself tho. But the order and the regex is quite important here, since each following match results in a substituion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜