Xampp Vhost无法使用不同的端口

时间:2014-11-05 09:13:37

标签: php ajax xampp vhosts

我在xampp中创建了一个虚拟主机。我不能使用端口80所以我使用端口8080.然后我调用servername:8080来获取index.php。它工作正常,但我无法进行ajax调用,然后发生错误。有什么问题?

虚拟主机

 <VirtualHost 127.0.0.1:8080>
   DocumentRoot "somepath"
   ServerName servername
   <directory "somepath">
      usual stuff here
   </directory> 
 </VirtualHost>

调用index.php

http://servername:8080

错误ajax

GET http://servername:8080/contact.html 404 (Not Found) 
jquery-2.1.0.min.js:4l.cors.a.crossDomain.send jquery-2.1.0.min.js:4o.extend.ajax 
jquery- 2.1.0.min.js:4o.(anonymous function) jquery-2.1.0.min.js:4start_loading
 main.js:516click_internal_link main.js:547(anonymous function) 
main.js:670o.event.dispatch jquery-2.1.0.min.js:3r.handle

1 个答案:

答案 0 :(得分:0)

试试这个:(通过xampp面板打开Apache配置,最后添加以下内容:)

Setting Up Your VHOST
    =====================

    The following is a sample VHOST you might want to consider for your project.

    NameVirtualHost 127.0.0.1:80

VHOST for Windows
=====================

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/..." 
   ServerName localhost

   # This should be omitted in the production environment
   #SetEnv APPLICATION_ENV development
   #SetEnv APPLICATION_ENV production

   <Directory "C:/xamp/htdocs/...">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>
</VirtualHost>
在Windows主机

AND this:

   C:\WINDOWS\system32\drivers\etc
    Edit hosts:

    127.0.0.1 localhost
祝你好运;)