I don’t know why there is a slash missing after rewriting
The following is the go.php code
<?php
$url=$_GET['url'];
$url=urldecode($url);
echo $url;
?>
rewrite rules are as follows
RewriteEngine On
RewriteRule ^go/(.*)$ go.php?url= [QSA]
巴扎黑2017-05-16 17:06:19
Reference Why is Apache removing multiple slashes?
@Pekka 웃 pointed out that multiple adjacent /
不符合RFC标准,@Pekka 웃 猜测Apache被设计为将多个相邻的/
in the URI are merged into one.
Similarly, after searching, I learned that there is a configuration such as merge_slashes in nginx, which is used to enable or disable the function of merging two or more adjacent slashes in the request URI into one . The default configuration is Turn on . It can be seen that apache and nginx have consistent behavior when handling multiple adjacent /
in URI by default, and both follow the RFC standard.
As for the //
in http://localhost/go.php?url=http://www.163.com/, they are not merged into one, but
The //
in http://localhost/go/http://www.163.com/ are merged into one. It should be that the former complies with the RFC standard, while the latter does not.
I don’t have a deep understanding of the RFC standard, so the above statement may not be rigorous enough. If there are any mistakes, please point them out. But after understanding this level, I feel that it is almost enough. As for how to change the rewrite rules or code, please google it yourself.