2011-09-06 97 views
1

在我的PHP網頁,我想重定向如下:網址rewritting與Apache的mod_rewrite

​​

是使page2.php所需的查詢字符串,但我不希望在訪問者的瀏覽器中顯示的查詢字符串。我以爲我可以消除使用mod_rewrite查詢字符串如下:

RewriteEngine On 
RewriteRule ^page2\.php page2\.php? 

這只是消除了使page2.php查詢字符串(使它的方式表現不理想),並且還在瀏覽器的網址顯示的查詢字符串顯示區域。

我發現了其他的引用上去除查詢字符串,如mod_rewrite: remove query string from URL?,但是當我加入重定向到像[R =永久]規則,通過我的瀏覽器中顯示的URL從

localhost/admin/page2.php?id=123 

通過網頁去與顯示就好了,到

http://localhost/C:/xampp/htdocs/admin/page2.php 

在不加載網頁,而是顯示如下:

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 

如何重定向到需要查詢字符串的頁面,但是將來自訪問者的查詢字符串隱藏起來,以便它不會被瀏覽器顯示給他們?

+0

的.htaccess和mod_rewrite的犯規一般在本地主機 – swordfish

+0

工作以及你有*傳球TID *的另一種方法來使page2.php?其次,URL重寫不能用於修改瀏覽器中顯示的URL。它用於將相當的URL轉化爲醜陋的*內部*。 –

回答