2014-01-31 06:52

Apache VirtualHost无法正常工作

  • apache
  • php
  • javascript


The problem I'm having is getting the VirtualHost to work right. This is how I have the two setup:

<VirtualHost *:80>
    DocumentRoot "/Apps/XAMPP/htdocs"
    ErrorLog "/Logs/Workarea/Error.log"
    CustomLog "/Logs/Workarea/Access.log" common
    <Directory "/Apps/XAMPP/htdocs/Workspace">
        AllowOverride all
        Order allow,deny
        Allow from all

<VirtualHost *:80>
    DocumentRoot "/Apps/XAMPP/htdocs/REDIR"
    <Directory "/Apps/XAMPP/htdocs/REDIR">
        AllowOverride all
        Order allow,deny
        Allow from all

What this is supposed you do is redirect if you connect to to but for some reason, loads the same exact homepage as (instead of redirecting like it's supposed too). But as you can see both virtual hosts are pointed to a different directory:

/Apps/XAMPP/htdocs (The real Homepage) is what loads

/Apps/XAMPP/htdocs/REDIR (Redirection page) it's supposed to redirect to . This is what I have in the file:

<h1 style="text-align: center;">Redirecting you to the correct link</h1>

A simple redirect script, but instead of doing that, it just loads the homepage.

Attempts of Solution

  • Emptying cache
  • Restarting Apache multiple times
  • Checking the error log (Didn't have any errors that helped)

But, none of these solve my problem, which is why I'm asking this question now.

Apologies for any confusion, the very-similar links make it confusing to understand and read.

But to explain it better,

Connect to and notice how it redirects you to

What I want is basically the opposite, but the VirtualHosts aren't letting me do that.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享