开发者

Url rewriting with Apache mod_rewrite

In my PHP web page I want to redirect as follows:

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. I thought I could eliminate the querystring using mod_rewrite as follows:

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.

I found other references on removing querystrings, like mod_rewrite: remove query string from URL? , but when I add redirection to the rule like [R=permanent], the url displayed by my browser goes from

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开发者_Python百科 their browser?


Take a look at this blog article - Apache RewriteRule and query string

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜