Search code examples
apachehttpdebianvirtualhostlamp

Apache2 how to working www.example.com


I need help. I am sorry wrong write. My LAMP server i created virtual host working http://example.com a NOT WORKING http://www.exaple.com

<VirtualHost *:80>
  DocumentRoot "/var/www/example/1/public_html"
  ServerName example.com
  ServerAlias   www.example.com
  ServerAdmin webmaster@localhost 
  <Directory />
    Options FollowSymLinks
    AllowOverride all
  </Directory>
  <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
  </Directory>
  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  UseCanonicalName on
  <Directory "/usr/lib/cgi-bin">
    AllowOverride all
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/error.log
  LogLevel warn
  CustomLog /var/log/apache2/access.log combined
  <Directory "/var/www/example/1/public_html">
    allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

Solution

  • Considering that you have put a local mapping to example.com in /etc/hosts. Do you have same entry for www.example.com also?

    example of the /etc/hosts entry:

    127.0.0.1 example.com www.example.com

    or

    xxx.xxx.xxx.xxx example.com www.example.com

    (xxx.xxx.xxx.xxx being your hosting server IP)