目前在我的网站上的特殊页面我正在访问这样的页面: mydomainname.com/torrents.php?parent_cat=Movie
但我想访问这样的页面:
mydomainname.com/torrent.php/Movie 或者如果可能
mydomainame.com/Movie
在这里,我使用的代码可以帮助我。
$addparam = "";
$wherea = array();
$wherea[] = "visible = 'yes'";
$thisurl = "torrents.php?";
if ($_GET["cat"]) {
$wherea[] = "category = " . sqlesc($_GET["cat"]);
$addparam .= "cat=" . urlencode($_GET["cat"]) . "&";
$thisurl .= "cat=".urlencode($_GET["cat"])."&";
}
if ($_GET["parent_cat"]) {
$addparam .= "parent_cat=" . urlencode($_GET["parent_cat"]) . "&";
$thisurl .= "parent_cat=".urlencode($_GET["parent_cat"])."&";
$wherea[] = "categories.parent_cat=".sqlesc($_GET["parent_cat"]);
}
$parent_cat = $_GET["parent_cat"];
$category = (int) $_GET["cat"];
$where = implode(" AND ", $wherea);
$wherecatina = array();
$wherecatin = "";
$res = SQL_Query_exec("SELECT id FROM categories");
while($row = mysql_fetch_array($res)){
if ($_GET["c$row[id]"]) {
$wherecatina[] = $row["id"];
$addparam .= "c$row[id]=1&";
$thisurl .= "c$row[id]=1&";
}
$wherecatin = implode(", ", $wherecatina);
}
答案 0 :(得分:2)
你可以使用url rewrite来做到这一点;
RewriteEngine On
RewriteRule ^/(.+)$ torrent.php?parent_cat=$1
将它放在.htaccess文件中。有关网址重写的详细信息,请参阅here
通过这样做,当您转到网址mydomainname.com/torrent.php/Movie
时,它将在后端行为mydomainname.com/torrents.php?parent_cat=Movie