[英]Url rewriting with Apache mod_rewrite
In my PHP web page I want to redirect as follows: 在我的PHP网页中,我要重定向如下:
header("Location: page2.php?id=$tid");
The querystring is needed by page2.php, but I don't want the querystring displayed in the visitor's browser. page2.php需要querystring,但是我不希望查询字符串显示在访问者的浏览器中。 I thought I could eliminate the querystring using mod_rewrite as follows:
我以为可以使用mod_rewrite消除查询字符串,如下所示:
RewriteEngine On
RewriteRule ^page2\.php page2\.php?
This just removes the query string for page2.php (making it behave in a way not desired), and still displays the query string in the browser's url display area. 这只是删除了page2.php的查询字符串(使其行为不符合预期),并且仍在浏览器的url显示区域中显示查询字符串。
I found other references on removing querystrings, like mod_rewrite: remove query string from URL? 我找到了有关删除查询字符串的其他参考,例如mod_rewrite:从URL删除查询字符串? , but when I add redirection to the rule like [R=permanent], the url displayed by my browser goes from
,但是当我向[R = permanent]之类的规则添加重定向时,浏览器显示的网址从
localhost/admin/page2.php?id=123
with by a web page that displays just fine, to 通过一个显示效果很好的网页
http://localhost/C:/xampp/htdocs/admin/page2.php
where the web page is not loaded, but instead the following is displayed: 未加载网页的位置,而是显示以下内容:
Access forbidden!
You don't have permission to access the requested object.
It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
9/5/2011 9:57:19 PM
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
How can I redirect to a page that needs a querystring, but hide that querystring from the visitor so that it is not displayed to them by their browser? 如何重定向到需要查询字符串的页面,但对访问者隐藏该查询字符串,以使浏览器不会向他们显示该查询字符串?
看一下这篇博客文章-Apache RewriteRule和查询字符串
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.