【问题标题】:Redirect all traffic to home page, except for one page将所有流量重定向到首页,除了一页
【发布时间】:2016-07-29 19:12:38
【问题描述】:

我想将所有流量重定向到主页,但目录为 /google/ 的任何内容除外。我想保留默认的 Wordpress 重写,以便删除 index.php。

# Need to leave certain files alone
RewriteCond %{REQUEST_URI} !.(gif|jpeg|png|css|js|woff|ttf|eot|svg|otf|woff2|jpg)$ 

# No redirects on home page (obviously)
http://example.com

# Everything else should redirect back to http://example.com (home)
http://example.com/*

# All variations of the following should NOT redirect
http://example.com/google/
http://example.com/google
http://example.com/google/index.php

谢谢!

【问题讨论】:

    标签: wordpress apache .htaccess


    【解决方案1】:

    您必须使用此规则来实现您的用例。

    RewriteRule !^google($|/) http://example.com%{REQUEST_URI} [L,R=301]
    

    【讨论】:

    • 与默认的 WP 规则一起使用有什么用?我尝试了类似的规则,它们导致了重定向循环。如果可行,我会试一试并标记为答案。谢谢
    猜你喜欢
    • 2015-01-14
    • 2010-12-30
    • 2012-12-21
    • 2011-01-05
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-08
    相关资源
    最近更新 更多