【问题标题】:Rewrite wordpress preview URL using .htaccess使用 .htaccess 重写 wordpress 预览 URL
【发布时间】:2011-12-27 15:16:15
【问题描述】:

我正在尝试进行以下重写:

mydomain.com/?p=706&preview=true to
mydomain.com/index.php?p=706&preview=true

使用RewriteRule ^/?p=([0-9]+)&preview=true$ /index\.php [QSA,L]

但是它没有重定向,我做错了什么?

【问题讨论】:

    标签: apache wordpress .htaccess rewrite


    【解决方案1】:

    替换为:

    RewriteCond %{QUERY_STRING} ^p=([0-9]+)&preview=true
    RewriteRule . /index.php [QSA,L]
    

    QSA 表示“将请求中的查询字符串附加到替代 URL”

    【讨论】:

      【解决方案2】:

      删除/

      RewriteRule ^/?p=([0-9]+)&preview=true$ /index\.php [QSA,L]
                  ^^^
      

      所以...

      RewriteRule ^?p=([0-9]+)&preview=true$ /index\.php [QSA,L]
      

      【讨论】:

      • 感谢您的回答,但是您写的行导致内部服务器错误(500)。知道为什么吗?
      • 是这样吗?是一个正则表达式符号,所以应该转义为 \?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-16
      • 2013-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多