Redirect in cpanel with several wordpress sites
Hi, I have four wordpress on one domain name. I'm moving one to another domain name.
Example
mydomain.com/folder1 wordpress site would not forward
mydomain.com/folder3 wordpress site would not forward
Mydomain.com is in maintenance mode and will deleted soon. Are there tools in cpanel that could help me do this type of redirect?
Thank you for your time
Kim
-
You'll want a .htaccess rule in Apache to setup these rewrites. I think this should do the job: RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteCond %{REQUEST_URI} !^/folder(1|2|3)/ [NC] RewriteRule ^(.*)$ https://www.example.net/$1 [R=301,L,NC]
(tested on RewriteRule ^(.*)$ https://www.example.net$1 [R=301,L,NC]
redirect the full url (^(.*)$) tohttps://www.example.net
followed by the captured url ($1) using a 301 Permanent redirect message, not case sensitive and make this the Last rule in the set. Alternatively, there's:RewriteEngine on RewriteCond %{REQUEST_URI} !^/folder1/ [NC,L] RewriteCond %{REQUEST_URI} !^/folder2/ [NC,L] RewriteCond %{REQUEST_URI} !^/folder3/ [NC,L] RewriteRule ^(.*)$ https://www.example.net/$1 [R=301,L,NC]
Which goes: 1.RewriteCond %{REQUEST_URI} !^/folder1/ [NC,L]
: if the URL does NOT start with folder1 (not case sensitive), then make this this Last part of this rewrite match. 2,3 4: I'll leave you to work out those bits yourself :) 5:RewriteRule ^(.*)$ https://www.example.net/$1 [R=301,L,NC]
if none of the previous rules have caused a match, then redirect. (tested on Apache's Rewrite manual page a useful reference.0 -
Thanks @rbairwell !!! 0
Please sign in to leave a comment.
Comments
2 comments