【问题标题】:htaccess category link optimization to main sitehtaccess 类别链接优化到主站点
【发布时间】:2023-03-24 06:25:02
【问题描述】:

我有带有类别链接重定向到主站点的 htaccess 文件

看看我下面的代码

RewriteCond %{REQUEST_URI} ^/shop/test1(/)?$
RewriteRule (.*) http://example.com/test1 [R=301,L]

RewriteCond %{REQUEST_URI} ^/shop/test2(/)?$
RewriteRule (.*) http://example.com/test2 [R=301,L]

RewriteCond %{REQUEST_URI} ^/shop/test3(/)?$
RewriteRule (.*) http://example.com/test3 [R=301,L]

以上代码的其他优化方式

【问题讨论】:

    标签: php regex .htaccess mod-rewrite redirect


    【解决方案1】:

    这 3 条规则可以组合成一条规则

    RewriteEngine On
    
    RewriteRule ^shop/(test1|test2|test3)/?$ http://example.com/$1 [R=301,L,NC]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 1970-01-01
      • 2022-01-13
      • 2014-03-17
      • 2014-02-23
      相关资源
      最近更新 更多