2014-09-03 218 views
0

如何隱藏在URL參數(QUERY_STRING),但將其發送到頁面隱藏的,不可見的地址欄 例如:隱藏參數(查詢字符串)的URL(htaccess的)

我有這樣的:

http://localhost/project/company/redeem/category/Shirts/18?category_id=18 

我想:

http://localhost/project/company/redeem/category/Shirts.html 

但我想在PHP $_GET['sent']

以獲取發送參數

我試着重定向到沒有參數的頁面(沒有query_string)[R],然後給頁面一些參數(靜默)沒有[R]重定向(不改變地址本身)

我試圖在RewriteRule中使用。 htaccess與不同的標誌和不同的方式,但沒有任何工作

請建議。

+1

我建議使用POST你正在試圖做 – 2014-09-03 10:32:18

+0

http://stackoverflow.com/questions/17086732/hide-get-parameter-from-url什麼 – ALH 2014-09-03 10:49:54

回答

0

據我所知,你只能隱藏參數鍵(在這種情況下,「CATEGORY_ID」)使用RewriteEngine敘述:

RewriteEngine On 

然後用重寫規則這樣

RewriteRule ^project/company/redeem/category/Shirts/18/(regex of whatever you expect for your parameter)$ project/company/redeem/category/Shirts/18.php?category_id=$1 

不確定前18個是否重合或總是與category_id值相同。如果您也可以使用

RewriteRule ^project/company/redeem/category/Shirts/(regex of whatever you expect for your parameter)$ project/company/redeem/category/Shirts.php?category_id=$1 

如果您想使用$ _GET參數必須寫入到url 某處。您只能嘗試來隱藏它。

例如,如果你知道每個類別的名稱,你可以把它們放入網址而不是數字。可以說CATEGORY_ID 18是「V領中性恤」,你可以使用URL像

http://localhost/project/company/redeem/category/Shirts/V-Uni 

,並告訴你的腳本中使用類「V-統一」,而不是「18」。
的.htaccess:

RewriteRule ^project/company/redeem/category/Shirts/([a-zA-Z-]*)$ project/company/redeem/category/Shirts.php?category=$1