monoista Posted July 20 Posted July 20 (edited) Hello, I use custom domain with Helio Host at Namecheap. I am trying the following configuration in order to redirect domain.tld to www.domain.tld, however, it does not work. Could you please advise how to redirect domail.tld to www.domain.tld? URL Redirect Record @ https://www.domain.tld Permanent(301) A Record www Helio Host IP address Edited July 21 by monoista
MoneyBroz Posted July 20 Posted July 20 Try adding this line into your domains .htaccess file RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.tld [NC] RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301] i tested this and it worked for me. also make sure to replace domain.tld with the actual domain name you are using.
monoista Posted July 20 Author Posted July 20 Thank you, @MoneyBroz. Can I keep the DNS setting on Namecheap as is, or shall it be also changed? Also, the URL Redirect Record on Namecheap, should it he http:// or https://?
MoneyBroz Posted July 20 Posted July 20 6 hours ago, monoista said: Can I keep the DNS setting on Namecheap as is, or shall it be also changed? if the site works with the code above i don't see any reason of changing it other than personal preference. 6 hours ago, monoista said: Also, the URL Redirect Record on Namecheap, should it he http:// or https://? it can either be http or https depending on if your site has a valid ssl certificate or not. if so then it should be https.
monoista Posted July 21 Author Posted July 21 Unfortunately I experience some issues. When going to http://domain.tld, the request is redirected to https://www.domain.tld (per Namecheap setting) Then, when https://www.domain.tld is served by Helio, I receive cross-origin error because the files are served from https://domain.tld instead of the redirected https://www.domain.tld. Adding https://domain.tld redirect to https://www.domain.tld does not work, because Namecheap can redirect secure connection to only different domain.tld. Quote NOTE: Redirecting with a secure connection (HTTPS) is only possible to a different destination domain (e.g. http://www.domain.tld to https://www.anotherdomain.tld). If you need this type of redirect (HTTP >> HTTPS) or vice versa (HTTPS >> HTTP) within the same domain name (http://domain.tld to https://domain.tld) , it must be set up via the .htaccess file or Namecheap SSL plugin in cPanel, provided an SSL certificate is installed . https://www.namecheap.com/support/knowledgebase/article.aspx/385/2237/how-to-set-up-a-url-redirect-for-a-domain/ I assume that for similar reasons, https://domain.tld redirect to https://www.domain.tld does not work. Therefore, is the only option as follows? 1 Namecheap A Racord @ Helio's server IP address 2.1 configure .htaccess to redirect http://domain.tld to https://www.domain.tld 2.2 configure .htaccess to redirect https://domain.tld to https://www.domain.tld
monoista Posted July 21 Author Posted July 21 (edited) At the moment, this is the setting that works: 1 Namecheap DNS using ns1 and ns2.heliohost.org 2 .htaccess as follows RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.tld [NC] RewriteRule ^(.*)$ https://www.domain.tld/$1 [L,R=301] If the last line is just http (RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]), then the content gets blocked because of origin policy. Edited July 21 by monoista
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now