这是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
那么我该如何解决这个问题
请帮我解决这个问题,谢谢
最佳答案
听起来您正在尝试拥有 SEO/用户友好的网址...如果是这种情况,您必须修改网址的生成,如果有空格,请将其替换为字符“-”。我不明白这与 .htaccess 有什么关系...
但是,您没有指定语言,也没有详细说明如何获取这些网址,所以恐怕这就是我在当前状态下可以为您的问题提供的所有帮助。
关于php - 如何使用 php 删除 .htaccess 中的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26445754/