I want to redirect everything on old domain (but not the homepage because there is still content) to new domain's homepage.
Important: But I don't want to redirect the old homepage. Just the other subfolders like domain.com/*
How to do this? I think this code won't work.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond% {HTTP_HOST} ^ olddomain.com $ [ALEBO]
RewriteRule (. *) $ Http://www.newdomain.com/$1 [R = 301, L]
</ IfModule>
You may use this rule in site root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?olddomain\.com$ [NC]
RewriteRule . http://www.newdomain.com%{REQUEST_URI} [R=301,L,NE]
No spaces anywhere in your rule or condition. Also a dot in RewriteRule
makes sure to match anything but landing page.
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.