mod_rewrite doesn't work when applied with "virtualhost"

Discussion in 'Site & Server Administration' started by Sxperm, Aug 14, 2006.

  1. #1
    Hi there, I do test server by installed appserv 2.4.5 that come with

    Apache 1.3.34
    PHP 4.4.1
    MySQL 5.0.16
    phpMyAdmin-2.5.7-pl1

    and mod_rewrite has been enabled by default.

    It works well until I inserted "virtualhost" to create multiple-site in my l
    ocalhost by inserted these lines. in apache httpd config file. (line 152)

    Listen 80
    Listen 8080


    NameVirtualHost 127.0.0.1:80
    NameVirtualHost 127.0.0.1:8080

    <VirtualHost 127.0.0.1:80>
    ServerName www.test1.com
    DocumentRoot H:/test1
    </VirtualHost>

    <VirtualHost 127.0.0.2:80>
    ServerName www.test2.com
    DocumentRoot H:/test2
    </VirtualHost>

    <VirtualHost 127.0.0.3:80>
    ServerName www.test3.com
    DocumentRoot H:/test3
    </VirtualHost>

    What's wrong with my localhost? Please give me some suggestion.
     
    Sxperm, Aug 14, 2006 IP
  2. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think you can use 127.0.0.2 or 127.0.0.3 - only 127.0.0.1 is a valid localhost IP address. Use different port numbers instead:
    • <VirtualHost 127.0.0.1:80>
    • <VirtualHost 127.0.0.1:81>
    • <VirtualHost 127.0.0.1:82>
    But, if you're trying to create using virtual hosts, they should all have the same IP address and port:

    
    <VirtualHost 127.0.0.1:80>
    ServerName test1
    DocumentRoot H:/test1
    </VirtualHost>
    
    <VirtualHost 127.0.0.1:80>
    ServerName test2
    DocumentRoot H:/test2
    </VirtualHost>
    
    <VirtualHost 127.0.0.1:80>
    ServerName test3
    DocumentRoot H:/test3
    </VirtualHost>
    Code (markup):
    You will probably need to add these hostnames to your hosts file:

    
    127.0.0.1    localhost
    127.0.0.1    test1
    127.0.0.1    test2
    127.0.0.1    test3
    Code (markup):
    Hope this helps (I'm not 100% sure I'm right though - can someone else verify?).

    Cryo.
     
    Cryogenius, Aug 14, 2006 IP
  3. Sxperm

    Sxperm Notable Member

    Messages:
    4,386
    Likes Received:
    142
    Best Answers:
    0
    Trophy Points:
    225
    #3
    Thank you for your replied. I do following your instruction but still see 404 error when used mod_rewrite function. :D Any advice?

    Regards,
     
    Sxperm, Aug 14, 2006 IP