. htaccess file
[Plain]View Plaincopy
- <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/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
[Plain]View Plaincopy < param name= "allowfullscreen" value= "false" >< param name= "wmode" value= "Transparent" >
- <virtualhost *:80>
- Allowencodedslashes on
- DocumentRoot "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
Copyright notice: Can be reproduced at will, original not easy please indicate the original source Oh ~ http://blog.csdn.net/zhouzme
"Go" Apache questions about mod_rewrite encountering special symbols such as%2f or%5c (forward and backward slashes) cause URL rewriting to fail with 404 problems