使用的conf文件从一个子文件夹重定向URL到另一个/ Ubuntu的 [英] redirecting url from one subfolder to another using conf file / ubuntu

查看:128
本文介绍了使用的conf文件从一个子文件夹重定向URL到另一个/ Ubuntu的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 domain.com 网​​站
它位于 /无功/网络/主

我也开始另一个网站,我想对网址 domain.com/a/b
但实际的文件位置是 /无功/网络/主/ A / B / C

I also have started another web site which I want to be on url domain.com/a/b But the actual file location is /var/www/main/a/b/c

问题是我希望用户使用网址 domain.com/a/b 和获取文件 /无功/网络/主/ A / b / C

Problem is that I want the users to use url domain.com/a/b and get files from /var/www/main/a/b/c

所以,我发现域的conf文件在 /etc/apache2/sites-available/domain.com.conf

So I've found domains conf file at /etc/apache2/sites-available/domain.com.conf

它只有这个

<virtualhost *:80>
    ServerName domain.com
    DocumentRoot /var/www/main
</virtualhost>

现在阅读关于它不同的主题后,我一直在努力,添加此所以现在我domain.com.conf文件看起来像这样

Now after reading different topics about it I've tried to add this so now my domain.com.conf file looks like this

<virtualhost *:80>
    ServerName domain.com
    DocumentRoot /var/www/main
</virtualhost>

<virtualhost *:80>
    ServerName domain.com
    ServerPath /a/b/
    DocumentRoot /var/www/main/a/b/c
    RewriteEngine On
    RewriteRule ^(/a/b/.*) /var/www/main/a/b/c
    # ...
</virtualhost>

但是,这并不在所有的工作。
我在做什么错了?

But this does not work at all. What am I doing wrong ?

推荐答案

无需重写规则。刚刚成立的别名 /etc/apache2/sites-available/domain.com.conf

No need for Rewrite Rules. Just set up an alias in /etc/apache2/sites-available/domain.com.conf :

<virtualhost *:80>
    ServerName domain.com
    DocumentRoot /var/www/main
    Alias /a/b /var/www/main/a/b/c
</virtualhost>

然后重新启动Apache:

Then restart apache :

$ sudo service apache2 restart

这篇关于使用的conf文件从一个子文件夹重定向URL到另一个/ Ubuntu的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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