redirect email url

Hello,

I am trying to do the following:

I want to be able to setup a redirect for horde to a specific url. What I would like to happen is that when someone enters http://mail.mydomain.tld for it to redirect to http://mail.mydomain.tld/horde

I tried setting up in the apache aliases/redirect on “url redirects” “from - /horde to - http://mail.mydomain.tld” but that didn’t work. It still shows up my main page in mail.mydomain.tld instead of showing my horde login page.

Regards,
G

Hi there,

In the Aliases/Redirects section for your mail.mydomain.tld, try setting up a "Regexp URL redirect", with the following:

From: ^/$
To: http://mail.mydomain.tld/horde

That should work for you!
-Eric

Eric,

Thanks for the reply. In the from section, I entered exactly what you said and also in the To section and that didn’t work. I then tried to enter the following in the From section:

/horde/([^/])($) and in the To section http://mail.mydomain.tld/horde and I still see my main index page when I go to mail.mydomain.tld instead of the horde

Howdy,

Just to be sure, after entering those, did you hit both "Save" at the bottom of the Redirects and Aliases page, then "Apply" at the top-right of the screen?
-Eric

Hmmm…I only hit save…never the apply after the save. let me try that and I’ll let you know

Eric,

Fantastic, that worked. Now, could you explain exactly what ^/$ is actually doing? Thanks a bunch…working nicely

Regards,
G

Eric,

Actually, that caused a problem. It does the redirect to my horde but now if I go to www.mydomain.tld, that also takes me to my horde when that should actually point to my main page and not horde

Regards,
G

Hello,

Well, if it’s causing a problem, go ahead and remove what you added in, hit save, then apply again and it should be back to the way it was.

In regards to what ^/$ is – that’s a regular expression. It’s searching the URL string to see if it contains only a “/” character.
The ^ is a special character meaning beginning of the string, and $ represents the end of the string.

So technically, it’s searching for 3 things – the beginning of the string, immediately followed by a / character, immediately followed by the end of the string.

In regards to the redirection you’re trying to do – I think I might be confused as to what you’re looking to accomplish, maybe you can help me figure out where I’m going awry.

You had mentioned this:

"What I would like to happen is that when someone enters http://mail.mydomain.tld for it to redirect to http://mail.mydomain.tld/horde"

Which I initially interpreted as you wishing that a user going to “http://mail.mydomain.tld” would in turn be forwarded to “http://mail.mydomain.tld/horde”. It sounds like that may not be what you’re after though.

Can you try explaining again what you’re interested in getting this to do? Thanks!
-Eric

Oh I see, you’re saying going to “www.mydomain.com” takes you to Horde, I get it now.

So to be clear, you’re saying both “mail.mydomain.com” and “www.mydomain.com” both end up redirecting to Horde?
-Eric

Eric,

Yep, both www amd mail end up at Horde when mail should just end up at Horde and www at the main site.

Also, thanks for the explanation of the expressions :slight_smile:

Still here trying to figure out the redirect though…hmmm

Mmmm… Can you go into Services -> Configure Website -> Edit Directives, and paste in the Apache directives for your mail.mydomain.tld domain?

That might shed some light on the behavior you just described.

Thanks,
-Eric

Ok,

Here is what I have in "Edit Directives"

SuexecUserGroup "#504" "#505"
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAlias lists.mydomain.com
DocumentRoot /home/domain_name/public_html
ErrorLog /home/domain_name/logs/error_log
CustomLog /home/domain_name/logs/access_log combined
ScriptAlias /cgi-bin/ /home/domain_name/cgi-bin/
ScriptAlias /awstats /home/domain_name/cgi-bin
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/domain_name/public_html>
Options Indexes IncludesNOEXEC FollowSymLinks ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php4
AddHandler fcgid-script .php5
FCGIWrapper /home/domain_name/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/domain_name/fcgi-bin/php4.fcgi .php4
FCGIWrapper /home/domain_name/fcgi-bin/php5.fcgi .php5
</Directory>
<Directory /home/domain_name/cgi-bin>
allow from all
</Directory>
<Files awstats.pl>
AuthName "mydomain.com statistics"
AuthType Basic
AuthUserFile /home/domain_name/.awstats-htpasswd
require valid-user
</Files>
PerlRequire /etc/webmin/virtualmin-google-analytics/apachemod.pl
PerlOutputFilterHandler Virtualmin::GoogleAnalytics
RedirectMatch /cgi-bin/mailman/([^/])(.) "https://mydomain.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2"
RedirectMatch /mailman/([^/])(.) "https://mydomain.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$2"
RedirectMatch ^/$ "http://mail.mydomain.com/horde"
Alias /pipermail "/var/lib/mailman/archives/public"
php_value memory_limit 32M
RemoveHandler .php
RemoveHandler .php4
RemoveHandler .php5
IPCCommTimeout 31
<Directory "/home/domain_name/horde">
</Directory>

As an aside, you’re making changes to your Apache config – I’d make sure you have a backup of it handy before making changes in case something doesn’t go as expected :slight_smile:
-Eric

Eric,

Pretty close. www.mydomain.com now goes fine to my main page but the redirect rule in apache didn’t work quite well. I get this error from firefox:

Redirect Loop

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.

* Have you disabled or blocked cookies required by this site?
* NOTE: If accepting the site's cookies does not resolve the problem, it is likely a server configuration issue and not your computer.

Ok,

I will try this. Looking at my log file with the previous code in the directives was growing my access_log file enormously. It was up to 1.4M in less than 5 mins…YIKES!!..lol

Hmmmm…nothing broke but it’s not redirecting either with the new condition. Just displays whats on the www page rather than going to horde

I really do appreciate you big help here :-)…thanks a million

NEVERMIND…I had to flush dns in windblows ;-). IT WORKS!!!..thanks so much!!!

Hrm, I don’t see mail.domain_name.com listed in there anywhere as a server alias. That leads me to suspect that it’s not in a virtual host anywhere, and that mail.domain_name.com always points to the default virtual server on your box.

That’s okay, I’m just thinking out loud so you can make sure I’m on track :slight_smile:

If that’s the case, I might add this to your “Edit Directives” section, immediately after the line “DirectoryIndex index.html index.htm index.php index.php4 index.php5”:

[code:1]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail.your_domain.com$ [NC]
RewriteRule ^(.*) http://mail.your_domain.com/horde
[/code:1]

Also, I still see the redirect you added in there from earlier today, don’t forget to take that out (you might even want to do that first).

Make sure you hit ‘Apply’ after making any changes, which restarts Apache.
-Eric

Hrm, I don’t see mail.domain_name.com listed in there anywhere as a server alias. That leads me to suspect that it’s not in a virtual host anywhere, and that mail.domain_name.com always points to the default virtual server on your box.

That’s okay, I’m just thinking out loud so you can make sure I’m on track :slight_smile:

If that’s the case, I might add this to your “Edit Directives” section, immediately after the line “DirectoryIndex index.html index.htm index.php index.php4 index.php5”:

[code:1]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail.your_domain.com$ [NC]
RewriteRule ^(.*) http://mail.your_domain.com/horde
[/code:1]

Also, I still see the redirect you added in there from earlier today, don’t forget to take that out (you might even want to do that first).

Make sure you hit ‘Apply’ after making any changes, which restarts Apache.
-Eric

Oh oops :slight_smile:

Try this instead of what I said earlier:

[code:1]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail.your_domain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*) http://mail.your_domain.com/horde
[/code:1]

We don’t want all requests going to mail.your_domain.com being redirected, only those going to “/” – and adding in the above REQUEST_URI condition should fix that.
-Eric