PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 22, 2022

[FIXED] How to restrict apache virtual hosts?

 September 22, 2022     apache, virtualhost     No comments   

Issue

I have one site enabled, for example foobar.com.
But when I open IP address 127.0.0.1 - it's opens my foobar.com.
Whatever maps to 127.0.0.1 in /etc/hosts I open - foobar.com is opened.

How can I configure virtualhost/apache to only allow access from foobar.com?

Apache 2.4, Ubuntu 13.10


Solution

Apache always uses the first VirtualHost as the "default" host. That is, whenever it can't map the requested hostname (127.0.0.1 in your case) to a specific VirtualHost, it will use that default one.

Just define another VirtualHost before the foobar.com one. If you have both in the same configuration, configure the default one first. If you have separate config files, name the "default" one so, that it gets loaded before the foobar.com one. Many Linux distributions use a name like 00-default.conf for the default VHost.



Answered By - mbirth
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing