I have written a rewrite rule in the .htaccess
file that will replace any spaces in the URL with .
(dots).
It works fine unless there are numbers in the URL.
RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ . [N,E=NOSPACE:1,DPI]
Any help is greatly appreciated
/search/test test
= Using the above regular expression will work/search/ 123 123
= Not working
In the regular expression character class, the characters
). Therefore, any number containing
at all.
%
,2
, and0
are treated as 3 literal characters instead of a single URL-encoded Space (i.e.2
or0
that also contains or is followed by a space will fail because the regular expression cannot match.RewriteRule
pattern matches the decoded URL path, so there is no need to try to matchSo, you just need to remove
from the rule. For example: