Can only access site using www (know cause but not solution)

I set up my LAMP server with Exim and now after it is all setup I can only access my site with www and not without it.

Without the "www" I see…

It works!
This is the default web page for this server.

The web server software is running but no content has been added, yet.

I have uploaded a simple index.html file into my public_html folder and with the "www" I see file loads.

Anyone have any insight on what may be causing this?

Thank you in advance from a rookie Linode user.

Additional info…

It had been working fine for me with Drupal installed and then this issue occured. I could not figure out my issue and reinstalled my linux distrobution to see if that fixed it and I also removed my DNS settings and started fresh there as well. Neither seemed to have worked.

7 Replies

Oooo I love guessing games.

1st guess - did you check to see if both domain.com and www.domain.com resolve correctly?

I have narrowed it down to my exim install. I reinstalled everything again and once I installed exim it caused the issue of not allowing me to visit my site without the www.

I followed this step by step.

http://library.linode.com/email/exim/se … 0.04-lucid">http://library.linode.com/email/exim/send-only-mta-ubuntu-10.04-lucid

Any ideas? My test emails do work.

Also I installed my LAMP server off of the Linode guide.

Thanks.

I am narrowing this down. This is the specific spot where my error is….

Before proceeding, make sure your /etc/hosts file has valid entries. For reference, your file should resemble the following:

File: /etc/hosts

127.0.0.1     localhost.localdomain     localhost
12.34.56.78   hostname.yourdomain.com   hostname
Be sure to replace "12.34.56.78" with your Linode's IP address. Replace "hostname.yourdomain.com" with your Linode's fully qualified domain name. Next, make sure your hostname is set in /etc/hostname by issuing the following commands (insert your one-word hostname in place of "hostname").

echo "hostname" > /etc/hostname
hostname -F /etc/hostname
Issue the following commands to check your setup:

hostname
hostname -f
The first command should return only the one-word hostname for your system, while the second command should return the system's FQDN.

If I add…

12.34.56.78   hostname.yourdomain.com   hostname

with my server ip, domain.com domain

It is causing my issue. Any thoughts? If I remove the second line it does not.

[b]127.0.0.1 localhost.localdomain localhost [/b] 12.34.56.78 hostname.yourdomain.com hostname

I just kept the first line and did not include the second and all is well. Everything is working as it should. Any issues I may see from it?

Alright, just throwing this out there. Would sticking a .htaccess file in the website root (/srv/www/yourdomain.com/) with modrewrite enabled in Apache work? If you haven't tried the .htaccess route, make a .htaccess file and put this as the contents (and make sure modrewrite is enabed): RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain.com RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

I do have mod_rewrite enabled so I can have clean urls in drupal. Overall it works now so I am content.

Thanks for the help.

I will say one thing… the extra work it took to learn how to set all of this up was well worth it. I have never had a site run this fast. Very pleased.

Reply

Please enter an answer
Tips:

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] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct