Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache Redirecting to first available site

Status
Not open for further replies.

Five9

IS-IT--Management
Sep 25, 2013
2
US
I have an issue with my Apache config. I'm an Apache novice and can't seem to figure this one out. I have about a dozen websites hosted on my apache server. I recently removed one but forgot to update external DNS so I still had users trying to hit the site. To my surprise, rather than being presented a 404 error they were redirected to the first site on my server. The URL in the browser did not change however???

User requested: (which has been removed)
Apache sends back the contents of: The User URL still reads:
Why would apache present a different site than requested and how can I tell it to just throw a 404 error?

Thanks in advance!
 
If the entire site has been removed there will be nothing to generate a HTTP 404 response and apache will serve the content of the first virtual host specified in httpd.conf and will use the host:hostname in the request headers, NOT the HTTP_HOST returned from the server.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks! I figured that out after combing through all the conf files. I just created a Virtual host named 404 and created a simple index file that says "Website not found". Not the cleanest method but better than users being directed to a different site than the one they requested. Less confusing at least.

Thanks
 
The 'default site' HAS to be the VERY FIRST virtual host in httpd.conf, and should respond to a IP wildcard,

Code:
<VirtualHost *>
DocumentRoot /home/default/public_html/
ServerName web.domain.tld
</VirtualHost>

Put whatever message you want visitors to see on index.html in the root directory

And replace "/home/default/public_html/" with your own document root directory obviously.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top