Question

Website without www not working however with www its works.

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.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.