【问题标题】:Xampp Vhost not working with different portXampp Vhost 不能使用不同的端口
【发布时间】:2015-01-01 09:56:06
【问题描述】:

我在 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

【问题讨论】:

    标签: php ajax xampp vhosts


    【解决方案1】:

    试试这个:(通过 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 主机中

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

    祝你好运;)

    【讨论】:

    猜你喜欢
    • 2014-10-24
    • 2017-11-10
    • 2015-03-12
    • 2015-01-22
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    • 2016-11-05
    相关资源
    最近更新 更多