访问本地计算机上的子域

I have PHP source code of http://www.sitename.com. This site is located on Windows Operating System and Apache Web Server.

I have .htaccess file as follows,

    DirectoryIndex index.php

RewriteEngine on
    # THE MAIN sitename SITE
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)/images/(.*)   C:/wamp/www/sitename/images/$2  [L]
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)/styles/(.*)   C:/wamp/www/sitename/styles/$2  [L]
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)/admin/(.*)    C:/wamp/www/sitename/admin/$2   [L]
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)/scripts/(.*)  C:/wamp/www/sitename/scripts/$2 [L]
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)/popup\.php(.*)    C:/wamp/www/sitename/popup.php$2    [L]
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)/robots\.txt   C:/wamp/www/sitename/scripts/robots.php [L]
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)/favicon\.ico  C:/wamp/www/sitename/favicon.ico [L]
    RewriteCond     %{HTTP_HOST}    (.*)sitename\       [NC]
    RewriteRule     ^(.*)$              C:/wamp/www/sitename/index.php  [L]



From live I got output for following URLs

  1. http://www.demo1.sitename.com
  2. http://www.demo2.sitename.com
  3. http://www.demo3.sitename.com .
    .
    .
    N. http://www.demoN.sitename.com



I have copied all source code from live and stored it on my local machine (Local IP is 192.168.15.24).

On local machine, Operating System is Windows XP and Apache Webserver.

I am trying to see the output on local machine which i saw on above N URLs.

I am unable to express equivalent URL for http://www.demoN.sitename.com to localmachine

e.g. 1. http://192.168.15.24/sitename/demoN
2. http://demoN.192.168.15.24/sitename/

How can i write URL so that i can access URL which is equivalent to http://www.demoN.sitename.com?

Edit %SYSTEMROOT%/system32/drivers/etc/hosts like the following :

127.0.0.1   www.demo1.sitename.local
127.0.0.1   www.demo2.sitename.local

Now go to your apache config file, and search for the VirtualHost section if any. If none, use this configuration code :

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "${path}/www/yourpath/demo1"
    ServerName www.demo1.sitename.local
    php_value include_path ".;${path}\www\yourpath\demo1"
</VirtualHost>

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "${path}/www/yourpath/demo2"
    ServerName www.demo2.sitename.local
    php_value include_path ".;${path}\www\yourpath\demo2"
</VirtualHost>

Now You can access to the local copy of your site using .local at the end of domain name instead of .com.

Please let me know if I understand correctly your demand.

Create sub domains you want these way: www.demoN.localhost

Add these domains to your HOSTS file. Edit c:\Windows\System32\drivers\etc\hosts Add lines like this 127.0.0.1 www.demoN.localhost

Make sure your virtual host in apache is configured for those domains.

Access your local version in browser using http://www.demoN.localhost/