【问题标题】:Multiple 301 Redirect for many page to 1 page多个页面的多个 301 重定向到 1 个页面
【发布时间】:2014-05-11 14:12:02
【问题描述】:

我有一个包含数百种产品和许多页面的网站,我已使用此规则重定向所有页面

重定向永久/about-us/ http://www.domain.com/wedding-blog/about

但现在我需要将我的所有产品重定向到另一个域页面,所有产品链接,像这样

/shopping/category.php?c=009591

他们是否以任何方式将我在 /shopping/ 下的所有产品在单个重定向规则中重定向到另一个域购物页面?

【问题讨论】:

    标签: php .htaccess redirect


    【解决方案1】:

    这应该可行:

    RewriteEngine On
    
    RedirectMatch 301 ^/shopping/(.*) http://example.com/shopping/
    

    它将/shopping/中的任何内容重定向到example.com/shopping/

    编辑:

    RewriteRule ^shopping/(.*)$ http://example.com/shopping.html? [R=301,L]
    

    【讨论】:

    • 谢谢你,我使用了这个并为我工作,唯一的问题是我发现所有重定向的 URL 都以 ?c=page_name 结尾,他们有什么方法可以删除它并只显示干净的重定向 URL?
    • 所以您不希望category.php?c=somenumber 出现在新网址上?
    • 是的,我不想要 '?c=anything',我只想显示新网址
    • 从 url 中删除 $1 应该这样做。
    • 先生,我已经删除了 $1 并使用了 RedirectMatch 301 ^/shopping/(.*) domain.com/shopping.html
    【解决方案2】:

    您必须使用mod_rewrite 规则来匹配查询字符串,并且将之前的规则也转换为mod_rewrite 是否更好:

    RewriteEngine On
    
    RewriteRule ^about-us/?$ /wedding-blog/about [NC,L,R=301]
    
    RewriteCond %{QUERY_STRING} ^c=009591$
    RewriteRule ^category\.php$ /some-page? [NC,L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-12
      • 1970-01-01
      • 2014-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-21
      • 2020-10-23
      相关资源
      最近更新 更多