How to properly code a 301 redirect for sub-domains
How to properly code a 301 redirect for sub-domains.
-
How should I code a 301 redirect for sub-domains when...
-
redirecting to a different sub-domain?
Example: http://business.townport.org/list
redirected to: http://newtown.portmaster.com/list/ -
redirecting the sub-domain to the main domain?
Example: http://business.townport.org/news/
redirected to: https://townmaster.org/events/
-
redirecting to a different sub-domain?
Answer:
#1: Assuming you want everything within http://business.townport.org/list to be redirected to the same file names and directory structured at http://newtown.portmaster.com/list/, you should add this code to your .htaccess file on the http://business.townport.org/ server:
RewriteRule ^list/(.*)$ http://newtown.portmaster.com/list/$1 [R=301,NC,L]
#2: To redirect the sub-domain to the main domain, add this redirect code to your .htaccess file also on the http://business.townport.org/ server
RewriteRule ^news/(.*)$ https://townmaster.org/events/$1 [R=301,NC,L]
That should do it.
Remember, we're always here to help you within FastAnswers. So, if you have questions or run into problems you're NOT alone in all of this!
...