【问题标题】:How to add redirection rule using htacess?如何使用 htaccess 添加重定向 URL?
【发布时间】:2021-01-14 16:44:20
【问题描述】:

我正在尝试编写 htaccess 重定向规则,用于将 url 从“abc.com/xyz”重定向到“abc.com/t1=xyz”。但规则不起作用。

RewriteEngine On
#RewriteRule ^xyz$ /?t1=xyz [L]

请帮帮我。

1.) abc.com/xyz output abc.com?t1=xyz
2.) abc.com/xzzz output abc.com?t1=xzzz

域后的值不固定,可以更改。 domain 之后的任何内容都应该是重定向后 t1 的值

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite url-rewriting


    【解决方案1】:

    您能否尝试按照您显示的示例编写以下内容。请确保在测试 URL 之前清除浏览器缓存。

    RewriteEngine ON
    RewriteCond %{REQUEST_URI} !^/?$
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^(.*)/?$ ?t1=$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2010-12-15
      • 2014-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多