Results 1 to 7 of 7

Thread: make it so webpage unavailable by IP?

  1. #1
    Join Date
    Nov 2008
    Location
    Sheffield, UK
    Beans
    1,514
    Distro
    Ubuntu

    make it so webpage unavailable by IP?

    I am trying to setup virtual hosts.

    I only want my website available via its www.domain.com address not my IP

    this is a snip of site available

    Code:
    <VirtualHost *:80>
            ServerAdmin webmaster@example.com
    ServerName example.com
        DocumentRoot /var/www/example.com/
        <Directory />
            Options FollowSymLinks
            AllowOverride All
        </Directory>
    Thats locked out other domains pointing at my IP but when I simply type IP in address bar I am sent to /var/www/example.com

  2. #2
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: make it so webpage unavailable by IP?

    When you are using virtual hosts if a page is requested by IP address instead of a URL it automatically matches the first enabled site, if you do an 'ls -l' of /etc/apache2/sites-enabled you'll find that your example.com file is top of the list.

    You can solve your issue by creating and enabling a new virtual host and naming it 000-whatever so that it is always first in the listing of available sites. Just create an error page or a redirect on this vhost to do whatever you want.
    Cheesemill

  3. #3
    Join Date
    Nov 2008
    Location
    Sheffield, UK
    Beans
    1,514
    Distro
    Ubuntu

    Re: make it so webpage unavailable by IP?

    Thanks cheesemill,

    Thats working now but it's now blocked the non www. address

    www.example.com works but not example.com

    Do I need two sites enabled or is there a better way?

  4. #4
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: make it so webpage unavailable by IP?

    Hi

    I'm sure there's a mod-security rule that can do this.

    Install mod security and the mod security core rule set.

    I'm open to correction if i am wrong though.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  5. #5
    Join Date
    Nov 2008
    Location
    Sheffield, UK
    Beans
    1,514
    Distro
    Ubuntu

    Re: make it so webpage unavailable by IP?

    just needed

    Code:
    ServerName example.com
    ServerAlias *.example.com


    Thanks all

  6. #6
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: make it so webpage unavailable by IP?

    Quote Originally Posted by SlugSlug View Post
    just needed

    Code:
    ServerName example.com
    ServerAlias *.example.com


    Thanks all
    That works for now, but what if you want to add a virtualhost of a subdomain like mail.example.com (e.g. for webmail) or members.example.com (e.g. for a members only sub-site)?

    Maybe safer replacing the * with www to leave subdomains with different sites possible?
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  7. #7
    Join Date
    Nov 2008
    Location
    Sheffield, UK
    Beans
    1,514
    Distro
    Ubuntu

    Re: make it so webpage unavailable by IP?

    ok thanks changed

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •