How can i make my website work with and with out www.

Hello, I have a website build with Django, using apache 2 web server, ubuntu for hosting. I am able to access it with
Can some one help me to be able to access it with Removing www. infront?

7 Replies

Linode Staff

DNS can certainly be a bit tricky to configure at times, and I've had my fair share of confusion in this subject. To understand DNS better, being familiar with what the DNS records are all about is a great first start.

Using your example, is your domain. The www. portion is consisdered the subdomain. If you want to be able to access your domain as just, this is determined when you configure your DNS.

When you are setting up the DNS, you will want to set up an A record with the hostname left blank, and the IP address with your website. This ensure that your domain of is resolved when an end-user enters into their browser.

If you still want end-users to be able to traverse to your website with the www. portion, you will need to configure a subdomain as well. You will create another A record, but this time your hostname will be www. Don't forget to use the same IP address.

If you want to do this with our DNS Manager, check out our guide on using it.

Take care and let us know how it goes! :)


Thanks for replying me back. I have already configured in DNS Records.

Please look below of what i have.

A/AAAA Record
Hostname -----IP Address------- TTL
-----ip_address------- Default
www --------- same_ip_address---Default

My Conf file:

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

I also did sudo service apache2 restart and when i open its showing me the below
Index of /
[ICO] Name Last modified Size Description
Apache/2.4.38 (Ubuntu) Server at Port 80

Any help on this?

Hey @raghavarahul

So this looks like this is now mainly an issue with the Apache configuration and not DNS. If you could provide more details of your configuration file, that would allow me to have a better understanding of what is going on.

In the meantime, check out some of our guides on Apache:
Apache Configuration Basics
Apache Configuration Structure
Updating Virtual Host Settings from Apache 2.2 to 2.4

Let us know if those guides lead you in the right direction, if not, get back to us with what else you have tried and we'll take it from there. Take care! :)

Hey Thanks for reaching me back.

These are the below config i am using in my apache2. Are you looking for anything different?

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

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

Any wrong in this configuration, please help me?

Hey @tpino, any help on above configuration?


Sorry about the delay. To set expectations properly, I want to clear it up that I'm not an expert on Apache, but I will certainly do my best to assist.

The DocumentRoot section needs to match exactly to where your website's .html file is located. If your index.html is located in `/var/www/html/', then you need to update your DocumentRoot to say:

DocumentRoot /var/www/html/index.html

Additionally, I have some other resources I have found for you:

Apache Configuration Files

Apache Configuration Sections

I hope this clears this up for you. Let us know how this goes. :)


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

The above lines mean: "when requested server name is, redirect the browser to same server name and URL but use the https protocol".

As you can see there, the "destination" address has the same server name as was originally requested. In other words, the above lines will redirect from http to https but not from www to no www.

If your goal is to rewrite "with www" to "without www", then you'll want something like this:

RewriteEngine on
RewriteCond %{SERVER_NAME}
RewriteRule ^{REQUEST_URI} [END,NE,R=permanent]


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct