简体   繁体   中英

Apache local VirtualHost redirecting to other VirtualHost

I'm trying to set up a simple WordPress dev environment using the Sage theme. I'm not too familiar with how VirtualHosts work, but I've just been following the steps I remember from setting one up in the past.

I have created a config file for my project:

<VirtualHost *:80>
  ServerName project1.loc
  DocumentRoot "/Library/WebServer/Documents/project1"
  ErrorLog "/private/var/log/apache2/project1.loc-error_log"
  CustomLog "/private/var/log/apache2/project1.loc-access_log" common

  <Directory "/Library/WebServer/Documents/project1">
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

There are a couple other config files exactly like this located in my vhosts directory.

In hosts:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##

127.0.0.1 project1.loc
127.0.0.1 project2.loc
127.0.0.1 project3.loc
127.0.0.1 project4.loc

127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

I've updated the devUrl in the manifest.json file of the Sage theme:

"config": {
    "devUrl": "http://project1.loc"
  }

I have restarted apache using: sudo /usr/sbin/apachectl restart

When I run gulp watch in the Sage directory, I get this:

[16:22:59] Using gulpfile /Library/WebServer/Documents/project1/wp-content/themes/project1/gulpfile.js
[16:22:59] Starting 'watch'...
[16:22:59] Finished 'watch' after 29 ms
[BS] Proxying: http://project1.loc
[BS] Access URLs:
 ----------------------------------
       Local: http://localhost:3000
    External: http://##.#.#.##:3001
 ----------------------------------
          UI: http://localhost:3001
 UI External: http://##.#.#.##:3001
 ----------------------------------

which seems fine. The problem is that this redirects to project3.loc for some reason. I can, however, access project1.loc/wp-admin or any other url that isn't the root just fine.

Is there a step I'm forgetting?

I figured it out. It was being cached. Clearing the cache fixed the problem. Dumb mistake.

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