Redirect folder to new domain

How do you redirect a folder to a new domain?

Here is a working example that we have in use for this very same change you may need to make.

This code is to be placed in your .htaccess file. If you do not know what you are doing, you could cause your site to 500 page error by simple typos. Please refer this page to your site’s developer or programmer.

WARNING. Improper use of htaccess or simple typo can render your site broken / inoperable. Don’t scream at your neighbor if you forget to make a backup of your file. Then, if things go wrong, you can just upload your original .htaccess file to the server. Backups are important, you have been politely warned.


##  top of htaccess:
RewriteEngine On
Options +FollowSymLinks

# first lets normalize our URL so that non www redirects to www
RewriteCond %{HTTP_HOST} ^m3server\.com$ [NC]
RewriteRule ^(.*)$ https://www.m3server.com/$1 [R=301,L]

#  our blog directory has moved to it's own site.  let's redirect it.
RewriteRule ^blog(.*)$ https://blog.m3server.com$1 [R=301,L]

#   end of primary redirect

Note: Replace our domain name with your domain name and our directory with your directory. This is an example only.

You can test this like so:
https://m3server.com/blog
https://m3server.com/blog/hi.text
https://www.m3server.com/blog/hi.text