How to process argument with dot in .htaccess?

51 Views Asked by At

I have this rule list in .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]

When I try to pass an argument with dot in the URL:

http://myurl.ru/e96fxk&example.com

it returns:

Not Found

The requested URL /e96fxk&example.com was not found on this server.

How to add the "dot" symbol in this rule:

RewriteCond %{REQUEST_URI} ^\/([абвгдеёжзийклмнопрстуфхцчшщьыъэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯa-zA-Z0-9\s_\[\]\{\}\+%&=-]+)$

?

1

There are 1 best solutions below

2
On BEST ANSWER

Your last rules seems to be overly complicated. You can use:

RewriteCond %{QUERY_STRING} !(?:^|&)query=[^&]+ [NC]
RewriteCond %{REQUEST_URI} ^/([^/]+)/?$
RewriteRule . /link_handler.php?query=%1 [L,QSA,B]