Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用php删除.htaccess中的空间_Php_Mysql_.htaccess_Redirect_Url Rewriting - Fatal编程技术网

如何使用php删除.htaccess中的空间

如何使用php删除.htaccess中的空间,php,mysql,.htaccess,redirect,url-rewriting,Php,Mysql,.htaccess,Redirect,Url Rewriting,这是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

这是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>
它是这样显示的

abc-123.html
abc-123%20xyz.html
假设我有一个这样的空间

abc-123 xyz.html
abc-123-xyz.html
 abc-123.html
所以它不起作用

它是这样表现出来的

abc-123.html
abc-123%20xyz.html
但没有结果

如果有空间的话,我想这样 然后像这样表演

abc-123 xyz.html
abc-123-xyz.html
 abc-123.html
如果找不到空间,则显示如下

abc-123 xyz.html
abc-123-xyz.html
 abc-123.html
那么我如何解决这个问题呢


请帮助我解决此问题,谢谢

听起来你在尝试SEO/用户友好URL。。。如果是这种情况,您必须修改URL的生成,如果是空格,则将其替换为字符“-”。我不明白这跟什么有关系。htaccess


但是,您没有指定语言,也没有详细说明您是如何获得这些URL的,因此我恐怕这就是我在当前状态下对您的问题所能提供的全部帮助。

如果您想要友好的URL,最好将所有内容捕获到一个入口点,如index.php,并在php内部处理URL,而不是在.htaccess上,特别是因为.htaccess比php慢得多

我是这样做的:


那么解决方案是什么?@user1796164,修改创建URL的过程,我已经说过了。。。如何使用取决于您使用的编程语言、使用的框架等。好的,我使用的是php get id$category=$\u get['category']$model=$\u GET['model']@user1796164,这不是URL生成方法。用代码的相关部分更新您的问题,但我相信您应该能够在字符串中用-替换``。有太多的教程可以帮助你,我有点看不出你到底有什么问题。听起来更像是你从别人那里得到了代码,却不明白到底发生了什么。。。