链接到相同管理文件的多个域


multiple domains linking to same administration files

如果这是基本的…我是配置方面的新手。

我已经建立了一个web应用程序,我想重用,但与较小的功能提供使用不同的域名,使它更容易为一些基本用户,我有困难找出最好的方法来做到这一点。

我试图避免复制"管理"后端,因为它将是相同的,只是一个菜单,不显示所有相同的功能(我将处理使用PHP显示的菜单项,并基于$_SERVER['SERVER_NAME']。但我需要两个不同的域名有单独的网页,所以我可以展示两个不同的网络应用程序。我不知道如何在apache中配置它,甚至不知道这是不是一个好方法。我知道如何用它们自己的文件夹结构创建两个独立的域,但我不知道如何使它们使用相同的管理员后端。

这是我的。

/数据/服务器/www.website1.com/web
/数据/服务器/www.website2.com/web

我为每个域名设置了一个虚拟主机,并为每个不同的网站设置了指向"web"文件夹的文档根目录。

在"web"文件夹下,我有以下结构

。/web/管理员

当用户访问"www.website1.com"时,需要为他们提供该网站的特定网页。当用户访问"www.website2.com"时,他们需要的是与#2网站相关的网页。但是,每个站点都有一个"登录"链接,指向位于"管理员"文件夹内的"Login.php"页面。这就是我困惑的地方,如何让它工作。登录后,我希望应用程序使用相同的web文件下找到"。/www.website1.com/web/administrator",这样我就可以更容易地管理维护。在应用程序中,我将根据用户来自哪个站点显示可用的菜单选项。我的希望是我可以使用我已经开发的"管理工具",而不必分叉代码并维护2个独立的代码库,我希望保留网站的结构,因为它已经有用户,我害怕把他们搞砸。

这可能吗?谁能帮我想一下我该怎么做才能做到这一点?

以下是我目前如何为website1.com设置虚拟主机:

<VirtualHost 123.33.432.123:80>
#  General setup for the virtual host
DocumentRoot "/data/servers/www.website1.com/web"
ServerName www.website1.com
ServerAlias *.website1.com
ServerAlias website1.com
ServerAdmin webmaster@website1.com
CustomLog "|/usr/local/sbin/cronolog /data/servers/www.website1.com/logs/access_log.%Y%m%d" "%h %l %u %t '"%r'" %s %b '"%{Referer}i'" '"%{User-agent}i'""
DirectoryIndex index.html index.php index.phtml index.htm index.php3 property-management-software.php
 <Directory "/data/servers/www.website1.com/web/">
    AddType application/x-httpd-php .php .html .htm
    Options none
    AllowOverride All
    Order Allow,Deny
    Allow from all
 </Directory>
</VirtualHost>

我想为website2.com添加另一个虚拟主机,就像这样:

<VirtualHost 123.33.432.124:80>
#  General setup for the virtual host
DocumentRoot "/data/servers/www.website2.com/web"
ServerName www.website2.net
ServerAlias *.website2.net
ServerAlias website2.net
ServerAdmin webmaster@website2.net
CustomLog "|/usr/local/sbin/cronolog /data/servers/www.website2.net/logs/access_log.%Y%m%d" "%h %l %u %t '"%r'" %s %b '"%{Referer}i'" '"%{User-agent}i'""
DirectoryIndex index.html index.php index.phtml index.htm index.php3 property-management-software.php
 <Directory "/data/servers/www.website2.net/web/">
    AddType application/x-httpd-php .php .html .htm
    Options none
    AllowOverride All
    Order Allow,Deny
    Allow from all
 </Directory>
</VirtualHost>

您可以使用Alias指令将URL映射到特定的文件/文件夹位置:

Alias /administrator /data/servers/www.website1.com/web/administrator

所以你会为你的其他域名创建第二个vhost,然后添加这个Alias,这样www.website1.com/administrator/www.website2.net/administrator/ URL都将指向你的文件系统中的同一个文件夹。

编辑:你可能还需要包含一个<Directory>指令来访问别名目录:
<Directory /data/servers/www.website1.com/web/administrator>
   AddType application/x-httpd-php .php .html .htm
   Options none
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>