我试图将我的WordPress多站点根站点重定向到另一个页面,但我仍然希望能够访问/wp-admin
,/wp-login
和/wp-json
。.htaccess不包括某些子目录的重定向网址
当我去浏览器时,我想url.com
重定向到newurl.com
除非它有上面的目录之一。
这就是我想到的,但是当我去浏览器并输入url.com
它像往常一样加载页面。我哪里错了?
注意:底部的块是重定向应该发生的地方。
Options FollowSymlinks
RewriteEngine On
RewriteBase/
# Force SSL/HTTPS
# Note: X-Forwarded-Proto is required for AWS's Elastic Load Balancing.
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule^- [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# This is the block that should redirect, but isn't.
RewriteCond %{HTTP_HOST} ^url\.com$ [NC]
RewriteCond %{REQUEST_URI} !^(/wp-admin$|/wp-login$|/wp-json$)
RewriteRule^http://newurl.com/ [R=301]
'似乎没有工作'。你可以说得更详细点吗 ?你试过的网址是什么? –
我试图访问'url.com',但它只是像往常一样加载页面,我已经更新了这个问题,使它更清晰一点。 – greg
它似乎对我很好。 –