[英]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.