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

Wednesday, September 21, 2022

[FIXED] How to access Apache VirtualHost via both Name & IP

 September 21, 2022     apache2, virtualhost     No comments   

Issue

I am using Apache VirtualHosts with 2 local domains on my home computer for development & testing.

• d4damage.local (personal websites)

• company.local (work stuff on external drive)

It's working perfectly on my network. However, I also need to optionally access d4damage.local via IP 192.168.1.60 (my computer is fixed to this IP)

The reason is my PS3 cannot resolve d4damage.local, but it can via IP. (all my other wi-fi devices are fine using d4damage.local)

It seems I can set d4damage.local to work on IP or name, but not both. (403 forbidden) the commented lines show the alternatives.

httpd-vhosts.conf

#NameVirtualHost 192.168.1.60:80
#<VirtualHost 192.168.1.60:80>
<VirtualHost *:80>
    ServerAdmin admin@d4damage.local
    DocumentRoot "/Users/paul/Sites"
    ServerName d4damage.local
    ErrorLog "/private/var/log/apache2/d4damage.local-error_log"
    CustomLog "/private/var/log/apache2/d4damage.local-access_log" common
</VirtualHost>

httpd.conf

ServerName d4damage.local
...
DocumentRoot "/Users/paul/Sites"
<Directory "/Users/paul/Sites">

hosts

127.0.0.1 localhost 
192.168.1.60 company.local d4damage.local 
255.255.255.255 broadcasthost 
::1 localhost 
fe80::1%lo0 localhost

The above files concern the main domain i wish to use on my computer, the company.local one is additional & i don't need to access that via IP.

Hope you can help! Thanks.


Solution

you will want to edit your hosts file, commonly found ´/etc/hosts´.

sudo nano /etc/hosts

and new line like this:

192.168.1.60  d4damage.local

Save the file and reboot.



Answered By - Faron
Answer Checked By - Gilberto Lyons (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