Here is my initial redirect rule:
RewriteCond %{HTTP_HOST} !^sub1\.myinitialdomain\.com$ [NC]
RewriteCond %{HTTP_HOST} !^sub2\.myinitialdomain\.com$ [NC]
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [L,R=301]
That basically redirects the entire website, except for sub1
and sub2
to the new domain.
However, I've got a wordpress install at /wordpress
and I've got the following rule in place to redirect all of the articles:
RewriteCond %{REQUEST_URI} wordpress
RewriteRule ^(.*)$ https://www.mydomain.com/blog/$1 [R,L]
But even though the articles are being redirected correctly, the main /wordpress
directory is not being redirected correctly. It's being redirected to https://www.mydomain.com/blog/wordpress
I need to be able to combine the rules, but make sure that /worpress
and any articles within that are being redirected to https://www.mydomain.com/blog/
You can use this rule to redirect everything from within /wordpress/.htaccess
file:
RewriteEngine On
RewriteRule ^(.*)$ https://www.mydomain.com/blog/$1 [NC,L,NE,R=302]
RewriteCond %{HTTP_HOST} !^(sub1|sub2)\.myinitialdomain\.com$ [NC]
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [L,NE,R=302]
Make sure this is first rule in /wordpress/.htaccess
file.
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.