【问题标题】:Rewrite query string with htaccess用 htaccess 重写查询字符串
【发布时间】:2018-06-03 10:53:31
【问题描述】:

我需要重写这个网址

category.php?cat=computers

category/computers

或者,反过来呢?

如何使用 .htaccess 做到这一点?

【问题讨论】:

    标签: php .htaccess mod-rewrite


    【解决方案1】:

    规则是:

        RewriteRule    ^category/(.+)/?$    category.php?cat=$1    [NC,L]
    

    您的 .htaccess 应该如下所示:

    <IfModule mod_rewrite.c>
        #if the name of the php file is the same of the path, you have to remove MultiViews
        Options +FollowSymLinks -MultiViews          
        RewriteEngine on
        RewriteRule    ^category/(.+)/?$    category.php?cat=$1    [NC,L]    
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 2010-11-16
      • 1970-01-01
      • 1970-01-01
      • 2012-11-15
      • 2013-02-19
      • 1970-01-01
      • 2016-03-04
      • 2011-04-06
      • 1970-01-01
      相关资源
      最近更新 更多