【问题标题】:Redirect everything except ?p=*重定向除 ?p=* 之外的所有内容
【发布时间】:2012-09-05 21:33:30
【问题描述】:

我如何配置一个 .htaccess 文件来重定向每个链接,除了

domain.com?p=*

domain.com/index.php?p=*

到 domain.com

希望你能理解我的问题,谢谢你的每一个回答。 来自德国的问候。

【问题讨论】:

    标签: apache .htaccess mod-rewrite redirect seo


    【解决方案1】:

    把它放在文档根目录的 htaccess 文件中:

    RewriteEngine On
    
    # if query string is p=(something)
    RewriteCond %{QUERY_STRING} ^p=
    # and request is for "/" or "/index.php"
    RewriteCond %{REQUEST_URI} ^/$ [OR]
    RewriteCond %{REQUEST_URI} ^/index\.php$
    # pass it through, don't do anything
    RewriteRule ^ - [L]
    
    # otherwise, redirect everything else to http://domain.com/
    RewriteRule ^ http://domain.com/ [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-01
      • 2014-10-26
      • 1970-01-01
      • 2017-02-18
      • 2012-11-04
      • 1970-01-01
      相关资源
      最近更新 更多