开发者

My .htaccess RewriteRule is "not working"

开发者 https://www.devze.com 2023-02-08 06:43 出处:网络
RewriteRule ^word-(.*)/(.*)/([a-z][a-z])/([0-9]+)?/$ /keywordb开发者_Python百科ycountry.php?word=yes&keyword=$2&cc=$3&page=$4 [L]
RewriteRule ^word-(.*)/(.*)/([a-z][a-z])/([0-9]+)?/$ /keywordb开发者_Python百科ycountry.php?word=yes&keyword=$2&cc=$3&page=$4 [L]

the $2 = is the keyword (anything) the $3 is the country code (only 2 lowercase letters) the $3 is the page (only numbers)

but for some reason it is not working


".*" might be the problem, it will match anything and therefore also '/' up until the strings end is reached.

use [^/]+ instead:

RewriteRule ^word-([^/]+)/([^/]+)/([a-z][a-z])/([0-9]+)?/$ /keywordbycountry.php?word=yes&keyword=$2&cc=$3&page=$4 [L]


RewriteRule ^word-(.*)/([a-z]+)/([a-z][a-z])/([0-9]+)?/$ /keywordbycountry.php?word=yes&keyword=$2&cc=$3&page=$4 [L]
0

精彩评论

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

关注公众号