Mail redirect like webmail redirect is

SYSTEM INFORMATION
OS type and version Ubuntu Linux 20.04.5
Webmin version 2.013
Usermin version 1.861
Virtualmin version 7.5
Theme version 20.13
Package updates All installed packages are up to date

Hello guys. I have a question for which I can’t find the answer. Assuming it is a simple task and people actually don’t have that problem, but somehow I can’t resolve it.

I run 5 sites and email for each site on the same server. When I configure MX and A record for mail.mydomain.com everything is working fine. However, from an SEO point of view, it is not a good idea for mail.maydomain.com to be accessible for web traffic.
Is there any good solution to my problem? Any chance I can redirect mail.mydomain.com to open the Usermin login screen instead opening my sites with email subdomain ? Something like webmail.mydomain.com redirect work?

Thank you all

webmail should work by default, takes you usermin login.

Yes, webmail works great. Can I make same redirect to mail.domain.com ?

well you could try just copy the current rule to suit in apache config.

RewriteCond %{HTTP_HOST} =mail.domain.com
RewriteRule ^(?!/.well-known)(.*) https://domain.come:20000/ [R]

1 Like

OK, this is the error message I get when make changes inside htaccess

Found
The document has moved here.

Additionally, a 302 Found error was encountered while trying to use an ErrorDocument to handle the request.

Also, I have made changes inside Virtualmin --> Services --> Configure Website --> Edit Directives without results. mail.mydomain.com opens homepage like there is no directive inside that file.

This is how my htaccess looks when I enter these directives

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} =mail.mydomain.com
RewriteRule ^(?!/.well-known)(.*) https://mydomain.com:20202/ [R]
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Hope someone have an idea.

In short, I want to redirect subdomain mail.domain.com to (webmail.domain.com:port)

your editing the domains section?
as you see I do a redirect to roundcude

P.S. I just added and tested, works fine, mine goes to roundcube.

image

Sorry didn’t read. You use the htaccess. I use Webmin – Servers – Apache Webserver. I edit the Virtual Server for the domain and use Edit Directives. For both port 80 and 443.

Well man thank you.

First of all, I tried both ways (htaccess & Webmin-Servers-Apache Webserver). Didn’t work.

Now, what I didn’t know that there are two directives (port 80 & port 443), and you gave me that clue. Yesterday I made changes for port 80, which is the reason it didn’t work. I use SSL and for that reason I didn’t saw any redirect.

Now it works great.

1 Like

I presume you meant “now” it works great :slight_smile: I mirror the 80 and 443.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.