How to configure virtualhost with mod_rewrite to work well together

Discussion in 'Apache' started by Sxperm, Aug 17, 2006.

  1. #1
    Dear all, I'm a newbie in Apache server. I've 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 and works very well.

    But I've found problem with mod_rewrite when I tried to inserted virtualhost in Apache httpd config file by add these lines.

    
    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>
    
    Code (markup):
    Now I can use different IP to call my website by enter

    http://127.0.0.1
    http://127.0.0.2
    http://127.0.0.3

    for call each site but mod_rewrite doesn't work with this config. I'm feeling that I did something wrong but I don't know which. Please give me some suggestion to get apache with virtualhost work with Apache mod_rewrite.

    Regards,
    Sxperm
     
    Sxperm, Aug 17, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Put the mod_rewrite code at domain.com/.htaccess and see if that works. If it doesn't, I don't know what would.
     
    Nintendo, Aug 17, 2006 IP
  3. Sxperm

    Sxperm Notable Member

    Messages:
    4,386
    Likes Received:
    142
    Best Answers:
    0
    Trophy Points:
    225
    #3
    Thank you for your help, Nintendo. However, .htaccess file does still exists and mod_rewrite worked very well before I put those codes in Apache httpd config file to created multiple-sites localhost. If I misunderstand something please give me some suggestion or example of coding to put them on. :D

    Regards,
    Sxperm
     
    Sxperm, Aug 17, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Make a post at webmasterworld.com/apache/

    The apache King lives there.
     
    Nintendo, Aug 17, 2006 IP