. Htaccess File
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>
Http: // localhost/application/home/index/URL/HTTP % 3A % 2f % 2fwww.domain.com % 2 fpage % 2f
When you access the above link, there is always 404, And the rewrite is invalid.
Http: // localhost/application/home/index/URL/http://www.domain.com/page/
XAMPP that I have been using in the local environment, nginx on the server is no problem, but Apache is quite speechless, always 404, changed to the original, but the page can be opened normally without urlencode
After searching online for half a day, I finally found the cause:
If % 2f (/) or % 5c (\) appears in the URL and path_info, it is considered invalid. Apache will directly return "404 (not found) "error.
That is to say, Apache directly rejects the request before calling the mod_proxy or mod_rewrite module, and returns the 404 error.
To prevent cgi security vulnerabilities, especially when path_info is used in the script but no security filtering operation is performed, the vulnerability is easily injected.
There are two solutions. The first one is relatively simple, but requires the server operation permission:
1. Modify the virtual directory configuration of the site
<VirtualHost *:80> AllowEncodedSlashes On DocumentRoot "D:/htdocs/localhost" ServerName localhost</VirtualHost>
Add allowencodedslashes on in configuration and then restart the service.
Ii. Multiple urlencodes
You can link the URL multiple times, usually twice or three times.
I did a test and found that it had to be successful three times.
Http: // localhost/application/home/index/URL/HTTP % 253a % 25252f % 25252fwww.domain.com % 25252 fpage % 25252f
It seems that this method is not practical, and the change is too large.
Apache mod_rewrite encounters a 404 error in URL rewriting failure caused by special symbols such as % 2f or % 5c (forward and backward slash ).