大家好,我尝试使用 mod rewrite 制作搜索结果 url
我的网址是这个
products/?categorie=2&subcategorie=&make=&p=2 (P is Page)
我试过这个
RewriteRule ^products([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /? categorie=$1&subcategorie=$2&make=$3&p=$4 [L]
在这个分页不起作用
我的 htaccess 看起来像这样
RewriteEngine On
# =========== Configuracoes Default =========== #
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_FILENAME} !^(.+)\.(css|js|xml|swf|pdf|doc|rtf)$
RewriteCond %{REQUEST_FILENAME} !^(.+)\.(jpg|png|gif)$
RewriteCond %{REQUEST_FILENAME} !^(.+)\.(ttf|otf|woff|eot|svg)$
RewriteCond %{REQUEST_FILENAME} !/php/acoes.php
RewriteCond %{REQUEST_FILENAME} !favicon.ico
RewriteCond %{REQUEST_FILENAME} !apple-touch-icon.png
RewriteCond %{REQUEST_FILENAME} !robots.txt
RewriteRule ^(.+)\/?([0-9]*)\/?$ php/index.php
#RewriteRule ^products([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /? categorie=$1&subcategorie=$2&make=$3&p=$4 [L]
我的 php 文件位于文件夹名称 php 中
我用于返回搜索结果的 php 文件是这样的
<?php
$Subcategorie_Id = mysql_real_escape_string($_REQUEST["subcategorie"]);
$Categorie_Id = mysql_real_escape_string($_REQUEST["categorie"]);
$Make_Id = mysql_real_escape_string($_REQUEST["make"]);
$SqlCount = "SELECT Product_Id FROM tabproducts WHERE Product_Status =1";
if($Categorie_Id) $SqlCount .= " AND tabproducts.Categorie_Id = '$Categorie_Id' ";
if($Subcategorie_Id) $SqlCount .= " AND tabproducts.Subcategorie_Id = '$Subcategorie_Id' ";
if($Make_Id) $SqlCount .= " AND tabproduct.Make_Id = '$Make_Id' ";
$QueryCount = mysql_query($SqlCount, $Conn) or die(mysql_error($Conn));
$RsCount = mysql_fetch_array($QueryCount);
$recordCount = mysql_num_rows($QueryCount);
if (!$_REQUEST["p"]) $p = 1;
else $p = $_REQUEST["p"];
$pageSize = 24;
$itemIni = ($pageSize*$p)-$pageSize;
$totalPage = ceil($recordCount/$pageSize);
?>