Report this

What is the reason for this report?

Website without www not working however with www its works.

Posted on June 25, 2021

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.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.