【问题标题】:Rewrite query string in .htaccess在 .htaccess 中重写查询字符串
【发布时间】:2011-04-06 13:57:00
【问题描述】:

我正在尝试对查询字符串进行非常简单的重写,但我一点运气都没有。我需要离开

http:// example dot com/?ACT=jquery

http:// example dot com/index.php?ACT=jquery

这是我在 .htaccess 文件中编写的代码,它会引发内部服务器错误。我对整个 mod 重写业务真的很陌生,所以任何帮助都将不胜感激。

RewriteEngine On
RewriteCond %{query_string} ^(ACT=jquery)$
RewriteRule ^(.*)$ index.php/?ACT=jquery

【问题讨论】:

    标签: string apache .htaccess mod-rewrite


    【解决方案1】:

    如果你只是想让它在不通知浏览器的情况下获取 php 文件:

    RewriteEngine On
    RewriteRule ^/\?ACT=jquery$ index.php/?ACT=jquery [PT,L]
    

    如果您希望浏览器更改书签等以创建锥形 URL:

    RewriteEngine On
    RewriteRule ^/\?ACT=jquery$ index.php/?ACT=jquery [R=301,L]
    

    假设任意参数:

    RewriteEngine On
    RewriteRule ^/\?(.*)$ index.php/?$1 [PT,L]
    

    或者您可能更喜欢脚本别名:

    ScriptAliasMatch ^(.*)\?(.*)$ index.php
    

    【讨论】:

      猜你喜欢
      • 2010-11-16
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 2012-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多