2
有問題。 我有一個頁面名稱users.php
此頁面顯示所選用戶和我的正常連接是這樣users.php?member=John
然後我改變它來清潔網址這樣users/member/John
但我的問題是,當你使用正常的URL它會正常工作訪問的頁面,但現在我有重寫它在我的.htaccess它會帶我到用戶的頁面,但沒有信息顯示它將是空的國防部重寫和PHP國防部重寫的.htaccess和PHP不工作在get方法
這裏是我的.htaccess
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+users\.php\?member=([^\s&]+) [NC]
RewriteRule^users/member/%1? [R=301,L]
RewriteRule ^users/member/([^/]+)/?$ users.php?member=$1 [L,QSA]
這是我的PHP代碼
<?php
if(isset($_GET['member'])) {
include($root . '_inc/dbconn.php');
try{
$db_conn = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME,DB_USERNAME,DB_PASSWORD);
$db_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmtData = $db_conn->prepare("SELECT * FROM users WHERE username=:getmember ");
$stmtData->bindParam(":getmember", $_GET['member']);
$stmtData->execute();
$UserData = $stmtData->fetch(PDO::FETCH_OBJ);
if ($UserData) {
$Dusername = $UserData->username;
$Dphoto = $UserData->photo;
$Demail = $UserData->email;
}
}
catch(PDOException $e)
{
echo "Error:" . $e->getMessage();
}
$db_conn = null;
}
?>
<?php echo $Dusername;?>
仍然是同樣的事情 – Micheal