【问题标题】:Redirecting specific folder to another folder and load a specific page using httpd.conf将特定文件夹重定向到另一个文件夹并使用 httpd.conf 加载特定页面
【发布时间】:2014-02-12 00:28:03
【问题描述】:

我有一个虚拟主机:www.example.com,其中包含两个子文件夹,即hellohello2hello 不包含任何内容,而 hello2 包含 test.html 文件。

现在我想做的是,每当我访问www.example.com/hello 时,我希望页面访问hello2 子文件夹中的test.html

样本输出:

网址:www.example.com/hello

回车后,

网址:www.example.com/hello2/test.html
页面显示:这是test.html



没有使用.htaccess只需使用httpd.conf配置,我怎么能做到这一点。我已经被困了好几个小时了。



这是我尝试过但没有运气的方法

<VirtualHost *:80>
        DocumentRoot /var/www/www.example.com/hello
        ServerName www.example.com
        ServerAlias www.example.com
        Alias /hello /var/www/www.example.com/hello2
        <Directory /var/www/www.example.com/hello2>
            #Options FollowSymLinks
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order deny,allow
            Allow from all
            RewriteEngine on
            RewriteRule ^/index\.html$ test.html [R]
        </Directory>
</VirtualHost>

提前谢谢你。

【问题讨论】:

    标签: php apache apache2 centos virtualhost


    【解决方案1】:

    我想把它放在httpd.conf

    <VirtualHost *:80>
            DocumentRoot /var/www/example.com
            ServerName www.example.com
            ServerAlias www.example.com
            Alias /hello /var/www/www.example.com/hello2
            RewriteEngine On
            Redirect 301 /hello http://www.example.com/hello2/test.html
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-08
      • 2021-03-16
      • 1970-01-01
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      • 1970-01-01
      • 2019-09-23
      相关资源
      最近更新 更多