开发者

Url rewriting with Apache mod_rewrite

开发者 https://www.devze.com 2023-04-03 00:04 出处:网络
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 brow

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

精彩评论

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