![](/img/trans.png)
[英]How to redirect to splash page and allow for images to display in .htacess rule?
[英]How to redirect page with htacess without sending id
我对.htacces
网址重写有问题。
我有一个名为dir
的文件夹,其中有三个文件
.htaccess
为空, i.php
也为空, 但在index.php
中,
$sql = mysql_query("SELECT * FROM clients ORDER By id DESC LIMIT 10");
while($row = mysql_fetch_array($sql)){
$url = "i/$row[id]/".preg_replace('/[^a-zA-Z0-9-_]/', '-', $row['company']);
echo "<a href='".$url ."'>".$row['company'].'<br/ ></a>';
}
当我将鼠标悬停在echo
输出类似
localhost/dir/i/101/today-in-news
localhost // is localhost obviously
dir // is a folder where I keep index.php and i.php files
i // is i.php
101 // is the id of the news
today-in-news // is the title of the news
因此,当我单击它时,它将带我到我想要的位置,但是我需要摆脱ID(在这种情况下为101
的ID,我希望当我访问时,链接仅是localhost/dir/i/today-in-news
点击它。 我已经尽力了,但是没有任何结果。
这段代码会将标题传递给i.php
,您可以在其中从数据库或其他任何东西中提取标题。 在这里查看一些.htaccess信息。
index.php :
$sql = mysql_query("SELECT * FROM clients ORDER By id DESC LIMIT 10");
while($row = mysql_fetch_array($sql)){
$url = "i/".preg_replace('/[^a-zA-Z0-9-_]/', '-', $row['company']);
echo "<a href='".$url ."'>".$row['company'].'<br/ ></a>';
}
.htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^i\/([a-zA-Z0-9_-])+\/?$ i.php?title=$1 [L]
</IfModule>
i.php
$title = $_GET['title'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.