I tried to access my internal website using http://localhost but I got error of:
|
1 |
403 Forbidden You don't have permission to access this resource |
I am able to access the website via 127.0.0.1
I have checked my files access and all is good.
Solution

1. Edit your default.conf add localhost as ServerAlias (sudo nano /etc/apache2/sites-enabled/default.conf)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port t> # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /home/wanrazali/data/www ServerAlias localhost ServerAlias 127.0.0.1 #rest of your configs |
2. Edit your hosts as below (sudo nano /etc/hosts/)
|
1 2 3 4 5 6 7 8 9 |
127.0.0.1 localhost # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters |
3. Restart Your Apache2 server
|
1 2 |
sudo service apache2 stop sudo service apache2 start |