首页 > 解决方案 > 虚拟主机重定向在 apache 中不起作用

问题描述

我创建了一个简单的虚拟域http://team.xyz.ae 一旦我点击这个 URL 我想将它重定向到http://team.xyz.ae/users/login but now its redirecting to

http://team.xyz.ae/users/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/loginusers/login

这是我为创建虚拟主机而写的

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/xyz/
    Redirect permanent / http://team.xyz.ae/users/login
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

标签: apachehttpd.confvirtual-hosts

解决方案


请参阅https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirectRedirect重定向以给定 URL 开头的任何请求。

您可能想RedirectMatch改用:

RedirectMatch permanent "^/$" http://team.xyz.ae/users/login

推荐阅读