. htaccess file
<ifmodule mod_rewrite.c>%{request_filename}-%{request_filename}-^ (. *) $ index.php/$1 [Qsa,pt,L]</IfModule>
Http://localhost/Application/Home/Index/index/url/http%3A%2F%2Fwww.domain.com%2Fpage%2F
When accessing the link above, the 404 is always present, and the rewrite is invalid.
http://localhost/Application/Home/Index/index/url/http://www.domain.com/page/
My local environment has been using the XAMPP, the server Nginx no problem, but Apache is very silent, always 404, replaced by the original, do not go through the urlencode but can open the page normally
Online search for half a day, and finally found the reason:
When%2f (/) or%5c (\) appears in the URL and path_info, it is considered an illegal request and Apache will return directly to the "404 (Not Found)" error.
In other words, Apache rejects the request directly before calling the Mod_proxy or mod_rewrite module, giving a 404 error.
This is done primarily to prevent CGI security vulnerabilities, especially if the script uses path_info but does not do a security filtering operation, it is easy to inject vulnerabilities.
There are two workarounds, the first of which is simpler, but requires the permissions of the server operation:
First, modify the configuration of the site virtual directory
<virtualhost *:80> allowencodedslashes on "d:/htdocs/localhost" ServerName localhost</VirtualHost>
Add Allowencodedslashes in the configuration to restart the service after the sentence
Second, multiple UrlEncode
Links can be urlencode multiple times, usually two times, or three times there will be no problem.
I did a test and found it had to be three times to succeed.
Http://localhost/Application/Home/Index/index/url/http%25253A%25252F%25252Fwww.domain.com%25252Fpage%25252F
I feel this method is not very practical, the change is too big
Apache about mod_rewrite encountering a special symbol such as%2f or%5c (forward and backward slash) causing URL rewrite to fail with 404 problem