Home > Mobile >  Domain name not redirecting
Domain name not redirecting

Time:10-17

My website can be accessed via https://example.com but can not be found using either https://www.example.com or www.example.com, if I use either of these it just throws up a "site cannot be reached" page.

Is this something I can change in the .htaccess file or is it the DNS of the domain?

I have tried adding the following code to the .htaccess file, but it makes no difference

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
 RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

CodePudding user response:

...or is it the dns of the domain?

Yes, this is "most probably" a DNS issue. The request is not even reaching your server by the sounds of it. .htaccess is consequently never processed.

You'll require a CNAME record that points the www subdomain to the domain apex (example.com) - so that both www.example.com and example.com point to the same place.

However, you also need to make sure that your server is accepting requests to both www.example.com and example.com - this doesn't happen by default. Although if you have configured your account via some hosting control panel then this has probably already been done for you. Otherwise, you need a ServerAlias record defined in the relevant <VirtualHost> container. For example:

ServerName example.com
ServerAlias www.example.com
  • Related