阿帕奇地图单子到文件夹 [英] apache map single subdomain to folder

查看:128
本文介绍了阿帕奇地图单子到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 /无功/网络我有一些网站(goodsite,badsite,uglysite)。现在他们是由 mydomain.com/goodsite 访问等。

In my /var/www I have a number of sites (goodsite, badsite, uglysite). Right now they are accessed by mydomain.com/goodsite, etc..

我要的是在particuar一个网站,uglysite,必须由 uglysite.mydomain.com 访问 - 其他人保持原状

What I want is for one site in particuar, uglysite, to be accessed by uglysite.mydomain.com - the others remain as they are.

我已经试过各种与the.htaccess摆弄的方式(以 /无功/网络)。注意:我已经启用了mod-rewrite并启用虚拟主机mod别名。

I have tried all sorts of ways of fiddling with the.htaccess (in /var/www). Note I have mod-rewrite enabled and mod vhost-alias enabled.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^uglysite\.mydomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/uglysite/
RewriteRule ^(.*)$ /uglysite/$1 [L]

什么最终情况是,无论mydomain.com和uglysite.mydomain.com始终映射到同样的事情(即在指数 /无功/网络)。我尝试添加一个新的虚拟主机,并惊讶地发现,uglysite.mydomain.com正确映射,但随后也mydomain.com直接映射到uglysite为好。

What ends up happening is that both mydomain.com and uglysite.mydomain.com always map to the same thing (i.e., the index at /var/www). I tried adding in a new virtual host, and was surprised to find that uglysite.mydomain.com mapped correctly, but then mydomain.com also mapped directly to uglysite as well.

<Virtualhost uglysite.mydomain.com:80>
       ServerName uglysite.mydomain.com
       ServerAdmin www@localhost
       DocumentRoot "/var/www/"
       AccessFileName .htaccess
       <Directory "/var/www/uglysite">
               Order allow,deny
               Allow from All
               AllowOverride All
       </Directory>
</VirtualHost>

以上加入到我的网站启用-/ 000-缺省文件。这引起了uglysite.mydomain.com正常工作,但随后mydomain.com映射到相同的事情!

The above was added to my sites-enabled/000-default file. This got uglysite.mydomain.com to work properly, but then mydomain.com mapped to the same thing!

有没有一种简单的方法做,我打算办??先谢谢了。

Is there a straightforward way to do what I'm intending to do?? Thanks in advance.

推荐答案

您应该做uglysite到第二个文件,而不是修改000默认

You should be making uglysite into a second file instead of modifying 000-default

所以,走000默认文件的一个副本,改变,因为你已经做了有子域和修改目录为/路径/要/网站

So, take a copy of the 000-default file, change the subdomain as you have done up there and modify the directory to /path/to/site

000默认:

<Virtualhost *:80>
       ServerName mydomain.com
       ServerAdmin www@localhost
       ServerAlias mydomain.com
       DocumentRoot "/var/www/goodsite"
       AccessFileName .htaccess
       <Directory "/var/www/goodiste">
               Order allow,deny
               Allow from All
               AllowOverride All
       </Directory>
</VirtualHost>

uglysite:

<Virtualhost *:80>
       ServerName uglysite.mydomain.com
       ServerAlias uglysite.mydomain.com
       ServerAdmin www@localhost
       DocumentRoot "/var/www/uglysite"
       AccessFileName .htaccess
       <Directory "/var/www/uglysite">
               Order allow,deny
               Allow from All
               AllowOverride All
       </Directory>
</VirtualHost>

另外要注意的是,上述样品中,我已经修改了的DocumentRoot 来指向你想要的文件从

编辑:virtualhosts设置为*:80因为你的网站指向你自己的IP反正

virtualhosts set to *:80 since your sites point to your own ip anyway

这篇关于阿帕奇地图单子到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆