【问题标题】:Two different Query string redirect to same structure Htaccess两个不同的查询字符串重定向到相同的结构 Htaccess
【发布时间】:2022-01-12 19:47:12
【问题描述】:

请帮帮我,我有两种情况,例如我有一个要重定向的URL,例如

https://example.com/about-us 我的重写规则是

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?pageName=$1 [QSA,L]

它适用于所有带有查询 pageName 的页面。

我想将不同的查询字符串重定向到相同的结构,就像我有 URL 一样

https://example.com/index.php?filter=latest

我想将其重定向到与上述关于我们页面相同的格式,例如

https://example.com/latest

这怎么可能?请帮助我,谢谢

【问题讨论】:

    标签: string .htaccess url-rewriting rules


    【解决方案1】:

    您不能对两个规则使用相同的格式或 URI 模式,但是您可以将第二个 URL 格式更改为类似于 https://example.com/second/latest 这里 second 可以是您想要添加到规则模式中的任何单词

     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^second/([^/]+)/?$ index.php?filter=$1 [QSA,L]
    

    记得将此规则放在顶部或现有规则之前。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-01
      • 2012-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多