I’m trying to redirect http://www.anydomain.com/rc to http://webmail.anydomain.com
It needs to work on all virtual domains.
This is what I have so far
RewriteCond %{REQUEST_URI} ^/rc(/?)$ [NC]
RewriteRule ^(.*)$ http://webmail.%{HTTP_HOST} [R=302,L]
This works for http://anydomain.com/rc which is correctly rewritten to http://webmail.anydomain.com
but it doesn’t work for http://www.anydomain.com/rc which becomes http://www.webmail.anydomain.com
Can anyone show me how to do this please?
Kind regards,
Peter
RewriteCond %{REQUEST_URI} ^/rc [NC]
RewriteRule .? http://webmail.hardcode-the-domain.tld [R=302,L]
That should work if you actually put the domain instead of using HTTP_HOST to fill it in. (HTTP_HOST will contain the www subdomain)
True, but that’s not going to work in my global httpd.conf for all virtual subdomains.
Lets see you config (httpd.conf) for these virtual domains.
RewriteEngine on
# Removing "www" subdomain.
RewriteCond %{HTTP_HOST} ^www\\.(.+)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} ^/rc [NC]
RewriteRule .? http://webmail.%{HTTP_HOST} [R=302,L]
This is one of them. They each have their own .conf files
<VirtualHost *:80>
ServerName www.domain1.com
ServerAlias domain1.com
DocumentRoot /var/www/html/www/public
ScriptAlias /cgi-bin/ /var/www/html/www/public/cgi-bin/
CustomLog /var/log/httpd/sites/www.bytes bytes
CustomLog /var/log/httpd/sites/www.log combined
ErrorLog /var/log/httpd/sites/www.error.log
<Directory /var/www/html/www/public>
Options +Includes -Indexes
</Directory>
</VirtualHost>
I’m hoping to put the solution in the main httpd.conf though.