如何避免我的Web浏览器在Windows7中使用WAMPredirect到本地主机?

我目前正在使用WAMP的Windows 7来尝试使用某些软件,但是我的浏览器不接受来自“localhost”域的cookie。 我试图通过将它们指向127.0.0.1在我的主机文件中创build几个假域,但是当我键入它们时,我自动redirect回到本地主机。 我还configuration了apache中的虚拟主机,以便与我添加到主机文件的域相对应,并且它仍然redirect回本地主机。 有什么特别的,我必须做的Windows 7绕过这个本地主机redirect?

感谢您的期待:)

我将在这里包含我的主机文件:

# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 127.0.0.1 magento.localhost.com www.localhost.com 

感谢您的期待:)

我有几个域以这种方式设置和工作正常,他们的关键是匹配ServerName主机中使用的别名(请注意,您不必在名称中使用.com或.net):

httpd.conf中

 NameVirtualHost *:80 <VirtualHost *:80> ServerName localhost </VirtualHost> <VirtualHost *:80> ServerName test DocumentRoot "D:/web/test" ErrorLog C:\Temp\Logs\Apache\test-error.log ; optional, but useful for development CustomLog C:\Temp\Logs\Apache\test-access.log common ; optional, but useful for development </VirtualHost> 

主机

 127.0.0.1 test 

这应该启用http://test/不redirect的请求。

这里有一个类似于我自己的PC上的C:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf的例子。

请注意,这需要您的计算机上有一个静态的IP地址; 不要在您用于开发的PC上使用DHCP。 正如Alberto所说,你需要在你的主机文件(在c:\ windows \ system32 \ drivers \ etc)中有相应的条目。

 <VirtualHost *:80>
     ServerName localhost
     ServerAlias localhost.config.local
     DocumentRoot“C:/ xampp / htdocs”
  <目录“C:/ xampp / htdocs”>
    选项索引FollowSymLinks包含ExecCGI
     AllowOverride全部
    订单允许,否认
    全部允许
  </目录>
 </虚拟主机>

 <VirtualHost *:80>
     ServerName 127.0.0.1
     ServerAlias 192.168.1.12
     DocumentRoot“D:/ www”
  <目录“D:/ www”>
    选项索引FollowSymLinks包含ExecCGI
     AllowOverride全部
    订单允许,否认
    全部允许
  </目录>
 </虚拟主机>

 <VirtualHost *:80>
     ServerName mypc
     ServerAlias mypc.config.local
     DocumentRoot“D:/网站/ www”
  <目录“D:/网站/ www”>
    选项索引FollowSymLinks包含ExecCGI
     AllowOverride全部
    订单允许,否认
    全部允许
  </目录>
 </虚拟主机>

为什么不使用本地IP(httx://192.168.xx)而不是httx://127.0.0.1或httx:// localhost?来浏览网站?

抱歉关于HTTP x

如果在/ etc / hosts中使用127.0.0.1作为虚假域,则它们将始终转到本地主机。

您应该使用您的网卡的IP地址,或添加一个辅助IP地址到您的网卡,并将其用于您的testing。