I would like to know how to redirect ONLY the Home Page of a Wordpress site to another domain.
Read a few other posts on this but none of them work.
This is what I've tried in my .htaccess
:
RedirectMatch ^/$ http://newsite.com
However ALL the pages on my site are being redirected to the new site.
Anyone have any ideas on what else to try?
Thanks.
Your URL will never reach /
it is always redirected to the domain without the trailing slash. While PHP will interpret the root of the domain as /
, the REQUEST_URI from Apache is actually looking for an empty string. This can be written as ^$
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ http://newsite.com [L]
</IfModule>
Just place this rule as very first rule in your WP .htaccess file:
%{THE_REQUEST} ^[A-Z]{3,}\s/+[\s?#]
RewriteRule ^$ http://newsite.com [L,R=301]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.