我在.htaccess中有这个规则列表:
RewriteEngine on
#RewriteCond %{REQUEST_URI} \/([0-9a-z&=\.\[\]{}%-]+)$ [NC]
RewriteRule \.incl$ - [R=404]
RewriteRule \.dist$ - [R=404]
RewriteRule ^handler/.*$ handler/handler.php? [L]
RewriteRule ^appsflyer/(.*)$ appsflyer.php$1 [L]
RewriteRule ^testlead/.*$ testlead/testlead.php? [L]
RewriteRule ^special/(.*)$ special/terminal.php$2 [L]
#RewriteCond %{REQUEST_URI} \/([a-zA-Zа-яА-Я0-9_[\]{}%&=-]+)$ [NC]
#RewriteRule ^(.*) /link_handler.php?query=%1 [L]
RewriteCond %{REQUEST_URI} ^\/([абвгдеёжзийклмнопрстуфхцчшщьыъэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯa-zA-Z0-9\s_\[\]\{\}\+%&=-]+)$
RewriteRule ^(.+)$ /link_handler.php?query=%1 [L,QSA]
当我尝试在URL中传递带点的参数时:
http://myurl.ru/e96fxk&example.com
它返回:
Not Found
The requested URL /e96fxk&example.com was not found on this server.
如何在此规则中添加“点”符号:
RewriteCond %{REQUEST_URI} ^\/([абвгдеёжзийклмнопрстуфхцчшщьыъэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯa-zA-Z0-9\s_\[\]\{\}\+%&=-]+)$
答案 0 :(得分:1)
你的最后规则似乎过于复杂。您可以使用:
RewriteCond %{QUERY_STRING} !(?:^|&)query=[^&]+ [NC]
RewriteCond %{REQUEST_URI} ^/([^/]+)/?$
RewriteRule . /link_handler.php?query=%1 [L,QSA,B]