我的mod_rewrite规则存在问题,我无法弄明白自己!
基本上我有一个国家/地区(100+)目录,根据网址显示(#worldwide)国家/地区信息。
我还有一个钓鱼俱乐部目录,我已经指示.htaccess忽略这个规则。这似乎对基本目录没有问题,但我无法将其重定向/钓鱼俱乐部/国家名称改为/fishing-clubs/index.php?country=COUNTRY
website.com//fishing-clubs/将前往/ fishing-clubs /目录。
但是网站http://fishing-clubs/name-of-country/发出404错误。
知道我的代码有什么问题吗?
RewriteRule ^fishing-clubs/ - [L,NC]
RewriteRule ^fishing-clubs/([A-Za-z0-9-\s_()]+)/?$ /fishing-clubs/index.php?country=$1 [NC]
#worldwide
RewriteRule ^([A-Za-z0-9-\s_()]+)/?$ country-admin-city.php?country=$1 [NC]
RewriteRule ^([A-Za-z0-9-\s_()]+)/([A-Za-z0-9-\s_()]+)/?$ country-admin-city.php?country=$1&admin1code=$2 [NC]
RewriteRule ^([A-Za-z0-9-\s_()]+)/([A-Za-z0-9-\s_()]+)/([A-Za-z0-9-s_()]+)/?$ country-admin-city.php?country=$1&admin1code=$2&admin2code=$3 [NC]
RewriteRule ^([A-Za-z0-9-\s_()]+)/([A-Za-z0-9-\s_()]+)/([A-Za-z0-9-s_()]+)/([A-Za-z0-9-s_()]+)/?$ country-admin-city.php?country=$1&admin1code=$2&admin2code=$3&city=$4 [NC]
答案 0 :(得分:1)
有这样的话:
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^fishing-clubs/?$ - [L,NC]
RewriteRule ^fishing-clubs/([\w()-]+)/?$ /fishing-clubs/index.php?country=$1 [NC,L,QSA]
#worldwide
RewriteRule ^([\w()-]+)/?$ country-admin-city.php?country=$1 [NC,L,QSA]
RewriteRule ^([\w()-]+)/([\w()-]+)/?$ country-admin-city.php?country=$1&admin1code=$2 [NC,L,QSA]
RewriteRule ^([\w()-]+)/([\w()-]+)/([\w()-]+)/?$ country-admin-city.php?country=$1&admin1code=$2&admin2code=$3 [NC,L,QSA]
RewriteRule ^([\w()-]+)/([\w()-]+)/([\w()-]+)/([\w()-]+)/?$ country-admin-city.php?country=$1&admin1code=$2&admin2code=$3&city=$4 [NC,L,QSA]