Question

Website without www not working however with www its works.

Posted June 25, 2021 137 views
ApacheWordPressUbuntu 20.04

My website www.mydomain.com is working fine but mydomain.com giving 403 Forbidden error.

I have Apache Ubuntu server. Here is my configuration.

My host file /etc/host

...
127.0.0.1 localhost
XX.XX.XX.32 mydomain.com www.mydomain.com

My mydomain.com.conf file

ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin admin@mydomain.com
DocumentRoot /var/www/mydomain.com/public_html


RewriteEngine on
RewriteCond %{SERVER_NAME} = mydomain.com [OR]
RewriteCond %{SERVER_NAME} = www.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

I already have configure A record to my IP address XX.XX.XX.32

I also set my CNAME to www.mydomain.com with TTL 43200

I have installed SSL for HTTPS as well. Having same above mydomain.com-le-ssl.conf

I already check root folder by removing with .htaccess its file. so no problem at htaccess file at all.

I am not sure what else I need to do. I am not able to access my website on mydomain.com or https://mydomain.com

Any suggestion please.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @ideveloper1990,

So you’ve configured your Hosts file. Let’s assume there are no typos there and see what can be causing the 403 Forbidden Error.

What I can suggest is for you to check your Apache Error Logs. That way you’ll see why exactly it’s giving the Error or if it’s at all reaching the Droplet. The Error log file should be located in /var/log/apache2/error_log or just somewhere in your /var/log/ folder.