如何更改Apache2中的默认链接结构?

时间:2022-10-05 18:30:18

I recently made my own LAMP-stack server for the first time, and I have a question regarding the link-building on my multiple domains.

我最近第一次创建了自己的LAMP堆栈服务器,我对我的多个域上的链接构建有疑问。

I have a single IP with about 30 domains, in its own folders. What I want to do, is to link the "root" to the root of the folder only. An example:

我在自己的文件夹中有一个包含大约30个域的IP。我想要做的是将“root”链接到文件夹的根目录。一个例子:

<img src="/logo.png"> in the file: 111.22.333.44/domain.com/testfolder/index.php
should show: 111.22.333.44/domain.com/logo.png instead of: 111.22.333.44/logo.png

How do I change this? I tried installing ISPConfig to make the domain folders, but it wont work anyway.

我该如何改变?我尝试安装ISPConfig来制作域文件夹,但无论如何它都无法工作。

I am running Ubuntu with PHP5 and Apache2.

我用PHP5和Apache2运行Ubuntu。

1 个解决方案

#1


Provide additional port for each of your site (if you don't have domains that point to your server). For example, 111.22.333.44:6000 for site_a, 111.22.333.44:6001 for site_b. Edit your /etc/apache2/ports.conf and make Apache to listen to ports

为您的每个站点提供额外的端口(如果您没有指向您的服务器的域)。例如,site_a为111.22.333.44:6000,site_b为111.22.333.44:6001。编辑/etc/apache2/ports.conf并使Apache监听端口

Listen 6000
Listen 6001
Listen 6002
...

Make sure your VirtualHosts respond to the respective ports and provide your DocumentRoot for each site

确保您的VirtualHosts响应各自的端口并为每个站点提供DocumentRoot

<VirtualHost 111.22.333.44:6000>
    ...
    DocumentRoot /path/to/your/site/document/dir
    ...
</VirtualHost>

Restart Apache and you can access the file

重新启动Apache,您可以访问该文件

111.22.333.44:6000/logo.png

#1


Provide additional port for each of your site (if you don't have domains that point to your server). For example, 111.22.333.44:6000 for site_a, 111.22.333.44:6001 for site_b. Edit your /etc/apache2/ports.conf and make Apache to listen to ports

为您的每个站点提供额外的端口(如果您没有指向您的服务器的域)。例如,site_a为111.22.333.44:6000,site_b为111.22.333.44:6001。编辑/etc/apache2/ports.conf并使Apache监听端口

Listen 6000
Listen 6001
Listen 6002
...

Make sure your VirtualHosts respond to the respective ports and provide your DocumentRoot for each site

确保您的VirtualHosts响应各自的端口并为每个站点提供DocumentRoot

<VirtualHost 111.22.333.44:6000>
    ...
    DocumentRoot /path/to/your/site/document/dir
    ...
</VirtualHost>

Restart Apache and you can access the file

重新启动Apache,您可以访问该文件

111.22.333.44:6000/logo.png