阿帕奇从根重定向重定向、阿帕奇

2023-09-02 09:54:01 作者:猪是的念来过倒

我只是想知道如何从根Apache的执行重定向。

我要检查,如果有人去根URL(如: example.com ),并将其重定向到 example.com/h 自动。

我能做到这一点的Apache的配置,或者在的.htaccess 文件?

解决方案

 了NameVirtualHost *:80

<虚拟主机*:80>
        服务器名example.com
        RedirectMatch 301 ^ / $ /小时
< /虚拟主机>
 

这将帮助您重定向从 example.com 您所有的要求 example.com/h

I was just wondering how to perform a redirect from root in Apache.

直升机的工作原理是啥

I want to check if someone goes to the root url (eg. example.com) and redirect them to example.com/h automatically.

Can I do this in apache config, or in a .htaccess file?

解决方案

NameVirtualHost *:80

<VirtualHost *:80>
        ServerName example.com
        RedirectMatch 301 ^/$ /h
</VirtualHost>

This will help you to redirect all your request from example.com to example.com/h