简体   繁体   中英

Xampp Vhost not working with different port

I created a virtual host in xampp. I cannot use port 80 so I'm using port 8080. I then call servername:8080 to get the index.php. It works fine but I cannot do an ajax call, then an error occurs. What is wrong?

vhost

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

Call index.php

http://servername:8080

Error 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

Try this: (open by xampp panel the Apache config and in the end add the following:)

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>

AND this: in your windows hosts

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

    127.0.0.1 localhost

Good luck ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM