apachehttpd.confvirtual-hosts

Virtual host redirection not working in apache


i have created a simple virtual domain http://team.xyz.ae once i hit this URL i want to redirect this to 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

this is what i have written to create a virtual host

<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>

Solution

  • See https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect, Redirect redirects any request starting with the given URL.

    You probably want to use RedirectMatch instead:

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