簡體   English   中英

使用.htaccess隱藏URL的一部分

[英]Hide part of URL with .htaccess

我有一個自動生成的網址。 例:

https://domain.com/folder/login/confirm.php?data=ujOeNXV3cVxuljf/username

這個URL是由moodle平台上的用戶注冊自動生成的,我想更改它,以便不顯示最終參數。 像這樣的東西:

https://domain.com/folder/login/confirm.php

要么

https://domain.com/folder/login

我怎么能在我的.htaccess中這樣做? 我有Apache WS 2.4和Ubuntu服務器。

你是說你不希望他們在地址欄中看到令牌嗎?

您可以做的是在confirm.php中,如果它作為GET請求進入,則將其重新發送回confirm.php作為POST。 它只會在地址欄中顯示,然后才會在處理時顯示

所以這樣的事情

<?php

if (isset($_GET["data"]){
$url = 'https://domain.com/folder/login/confirm.php';
$data = array('data' => $_GET["data"]);



// use key 'http' even if you send the request to https://...
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);

} else {

// if it's not set then you continue processing

}
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM