Jump to content

Recommended Posts

Posted (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 by monoista
Posted

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.

Posted

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://?

Posted
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.

Posted

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
 

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...