0
我的原始網址是/localhost/site/en/detail.php?id=1 & title = Hello%20World 我想要一個乾淨的網址:/ localhost/site/EN /職位/ 1 /您好,世界,但問題是,對象未找到,重寫URL:找不到對象(.htaccess)
從HTML請求
<a href="post/'.$rij['id'].'/'.$rij['title'].'"><div class="material"><i class="fa fa-1x fa-chevron-right"></i></div></a>
php文件和PHP處理程序:
$titlestring = mysqli_real_escape_string($db, $_GET['title']);
$idstring = mysqli_real_escape_string($db, $_GET['id']);
$query = "SELECT * FROM posts WHERE id=".$idstring;
我將做BIND後來變量
這是我htaccessfile
RewriteEngine on
RewriteBase/
#external redirect from actual URL to pretty one (remove query string)
RewriteCond %{THE_REQUEST} \s/+detail\.php\?id=$1&?title=([^\s&]+)
RewriteRule^%1? [R=302,L,NE]
# convert all space (%20) to hyphen
RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [N,NE]
RewriteRule "^(\S*) (\S*)$" $1-$2 [L,R=302,NE]
# rewrite rule to call actual PHP handler
RewriteRule ^post/([0-9]+)/([-a-zA-Z_-]+) detail.php?id=$1&title=$2 [L,QSA,NC]
我不認爲這是一個問題。我更新了我的代碼,並且我沒有在查詢中真正使用該標題, –