【问题标题】:URL query string rewrite in htaccess在 htaccess 中重写 URL 查询字符串
【发布时间】:2023-03-04 12:17:01
【问题描述】:

我正在尝试在我的.htaccess 文件中编写重写规则,但不知道如何让它工作。我想转换这个网址:

http://www.example.com/userskill/?lvl=100k

http://www.example.com/?lvl=100k

底层页面最终将是http://www.example.com/home.html?lvl=100k。如何在我的 .htaccess 文件中添加重写规则来执行此操作?

【问题讨论】:

    标签: apache .htaccess url query-string rewrite


    【解决方案1】:

    在 htaccess 之上,首先打开 RewriteEngine

    RewriteEngine On
    

    之后,您可以添加重写规则。这将是这样的:

    RewriteRule ^userskill/$ index.php [QSA,L]
    

    QSA 部分从 url 复制查询字符串。

    更多信息见

    http://forums.devshed.com/apache-development-15/question-about-query-string-in-a-rewrite-url-htaccess-557476.html

    http://vikrant_labde.blogspot.com/2008/07/querystring-in-htaccess-match-question.html

    【讨论】:

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