将所有流量重定向到主页,但一页除外

时间:2016-07-29 19:12:38

标签: wordpress apache .htaccess

我想将所有流量重定向到主页,除了目录为/ 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

谢谢!

1 个答案:

答案 0 :(得分:0)

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

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