www. mysite.com works, mysite.com doesn´t

Hi guys, if i enter http://mysite.com it shows:

It works!

This is the default web page for this server.

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

If i enter www.mysite.com is fine, how to make the http://mysite.com work?

Thanks for any help.

  • Maybe is a .htacces thing….

21 Replies

Assuming you're using Apache, what does your /etc/apache2/sites-available/000-default look like? Or, better yet, post the contents of all linked files inside /etc/apache2/sites-enabled (feel free to "censor out" your actual domain name and server paths, but make sure you keep the subdomain part of any domain names, such as "www", intact).

If I had to guess (without seeing what the actual config files look like), I'd say that ServerName and ServerAlias in the config file corresponding to your domain name only has one of these.

Inside /etc/apache2/sites-available/mysite

I see

ServerName mysite.com
ServerAlias www.mysite.com

Is that what you were guessing?

Thanks Neon

Are there links to any other files in /etc/apache2/sites-enabled? If so, what do they contain?

Grevan,

You might consider adjusting ServerAlias www.mysite.com to show ServerAlias www.mysite.com mysite.com

Ensure you have a DNS entry setup for mysite.com.

Remember to reload Apache when you're done.

@Mercer:

Grevan,

You might consider adjusting ServerAlias www.mysite.com to show ServerAlias www.mysite.com mysite.com

Ensure you have a DNS entry setup for mysite.com.

Remember to reload Apache when you're done.
You don't need to put the domain into ServerAlias when it's already in ServerName. And there is a DNS entry for mysite.com, since it does display a website (although from a different directory).

On that note, Grevan, please ensure that mysite.com is pointing to the same IP address as www.mysite.com.

1- /etc/apache2/sites-enabled

000-default

mysite.com

mysite2.com

mysite3.com

Neon, how do i ensure that mysite.com is pointing to the same IP address as www.mysite.com?

Just open up a command prompt window and use the command nslookup (Windows) or host (Linux), followed by the hostname, once with the www, and once without it. Then, compare the results. If you're getting the same IP address for both lookups, you don't have to do anything.

Yes, it´s getting the same IPs, but i got this message too for mysite.com:

mysite.com mail is handled by 10 mail.mysite.com

Not to worry, that response is normal (since the host command also checks for MX records as well as A/CNAME).

What does the 000-default file look like? Is there a reference to your domain name in any ServerName or ServerAlias directives there?

And going back to the original mysite.com file; please do double-check the spelling of your domain name in both ServerName and ServerAlias, just to be sure.

1- The 000-default file in /etc/apache2/sites-enabled:
> ServerAdmin webmaster@localhost

DocumentRoot /var/www

Options FollowSymLinks

AllowOverride None

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

allow from all

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Order allow,deny

Allow from all

ErrorLog /var/log/apache2/error.log

Possible values include: debug, info, notice, warn, error, crit,

alert, emerg.

LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks

AllowOverride None

Order deny,allow

Deny from all

Allow from 127.0.0.0/255.0.0.0 ::1/128

There are no ServerName or ServerAlias there.

2- I double checked the names and their are fine

Try running apachectl -S and see what it comes up with. It should show a list of virtual hosts (without aliases).

Neom, the command apachectl -s is not found.

Do i have to go to a certain directory to call it?

It's usually located at /usr/sbin/apachectl, and you don't have to be in any specific directory to call it (but the /usr/sbin location would in $PATH for the root user).

Also, keep in mind that the parameter for the apachectl is an uppercase S (not lowercase).

apachectl, the command is still not found, mmm

try /usr/sbin/apache2ctl

apache2ctl worked, but it gives a list of commands, -s doesn´t show anything.

I tried apache2ctl status, look what gives me:

****/usr/sbin/apache2ctl: 134: www-browser: not found

'www-browser -dump http://localhost:80/server-status' failed.

Maybe you need to install a package providing www-browser or you

need to adjust the APACHE_LYNX variable in /etc/apache2/envvars****

  • Just a note, my other sites can be accessed with www or without, only this one, which is also my FQDN domain and i only access with www.

the full command is

/usr/sbin/apache2ctl -S

prefix with sudo if you're running as a normal user.

make sure you're using an upper case S.

-S worked!

It shows the list of my sites enabled.

I don´t see anything wrong there.

The server's full hostname wouldn't happen to be "mysite.com", would it? If so, I suspect Apache might be keying off of that and displaying a default page, since the request would be coming in for the server's hostname instead of a virtual site…

Yes hoopycat,

in /etc/hostname and /etc/hosts it´s mysite.com there.

It's a long shot, but if that's the only host that isn't working right, try renaming the server to a proper name (i.e. webserver.mysite.com). That might cause Apache to be less confused.

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