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]
我不认为这是一个问题。我更新了我的代码,并且我没有在查询中真正使用该标题, –