【发布时间】:2014-10-18 23:48:50
【问题描述】:
这是php代码
$category = $_GET['category'];
$model = $_GET['model'];
//connect to database
mysql_connect('localhost','user','password');
mysql_select_db('user');
$result = mysql_query("SET NAMES utf8"); //the main trick
$q=mysql_query("select * from data where category='$category' And model='$model' AND TRIM(model) IS NOT NULL");
//Adds one to the counter
mysql_query("UPDATE daata SET counter = counter + 1 where category='$category' And model='$model'");
//Retreives the current count
$count = mysql_fetch_row(mysql_query("SELECT counter FROM data"));
$row=mysql_fetch_object($q);
echo mysql_error();
?>
<table class='hovertable'><?php if($row->model):?><tr class=\"style1\"><td width='200'><b>Model:</b></td><td><?php echo $row->model ?></td></tr><?php endif; ?>
<?php if($row->category):?><tr class=\"style1\"><td width='200'><b>Category:</b></td><td><?php echo $row->category?></td></tr><?php endif; ?></table>
我正在使用这个 .htaccess 文件
.htaccess
RewriteOptions inherit
RewriteRule ^([a-zA-Z0-9_-]+)-([0-9]+)\.html$ detail.php?category=$1&model=$2
它是这样显示的
abc-123.html
假设我有这样的空间
abc-123 xyz.html
所以它不工作
它是这样显示的
abc-123%20xyz.html
但没有找到结果
如果找到空间,我想要这样 然后像这样显示
abc-123-xyz.html
如果没有找到空间,则显示如下
abc-123.html
那么我该如何解决这个问题
请帮我解决这个问题,谢谢
【问题讨论】:
标签: php mysql .htaccess redirect url-rewriting