.htaccess to redirect domain1 to domain2
.htaccess to redirect domain1 to domain2 -
Solution :
Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about domains, htaccess, mod-rewrite, multiple-domains, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :I currently have a .htaccess file with the current lines to force HTTPS:
RewriteEngine On
RewriteCond %HTTPS off
RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301]
My main domain is example.com
I have a registered an alias in my cPanel: example.net
I would like to implement a rule so that if a user visits example.com, they will be redirected to https://example.net.
I've tried a few things and kept getting redirection errors.
Can someone help me out, not sure what I should be doing here?
Try the following instead:
RewriteEngine On
RewriteCond %HTTPS off [OR]
RewriteCond %HTTP_HOST !^example.net$
RewriteRule .* https://example.net%REQUEST_URI [R=301,L]
If HTTPS is off or the requested host is not example.net then redirect to HTTPS and example.net.
Comments
Post a Comment