Jump to content

Namecheap DNS configuration and www redirect


monoista

Recommended Posts

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 by monoista
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
 

Link to comment
Share on other sites

Posted (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 by monoista
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...