redirect email url

23 posts / 0 new
Last post
#1 Tue, 07/08/2008 - 04:37
Tito

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

Tue, 07/08/2008 - 05:00
andreychek

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

Tue, 07/08/2008 - 05:18 (Reply to #2)
Tito

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

Tue, 07/08/2008 - 05:25 (Reply to #3)
andreychek

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

Tue, 07/08/2008 - 06:35 (Reply to #4)
Tito

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

Tue, 07/08/2008 - 06:37 (Reply to #5)
Tito

Eric,

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

Regards,
G

Tue, 07/08/2008 - 07:04 (Reply to #6)
Tito

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

Tue, 07/08/2008 - 07:51 (Reply to #7)
andreychek

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

Tue, 07/08/2008 - 07:57 (Reply to #8)
andreychek

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

Tue, 07/08/2008 - 08:16 (Reply to #9)
Tito

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

Still here trying to figure out the redirect though...hmmm

Tue, 07/08/2008 - 08:47 (Reply to #10)
andreychek

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

Tue, 07/08/2008 - 09:03 (Reply to #11)
Tito

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>

Sun, 06/07/2009 - 07:26 (Reply to #12)
andreychek

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

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

Sun, 06/07/2009 - 07:26 (Reply to #13)
andreychek

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

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

Sun, 06/07/2009 - 07:26 (Reply to #14)
andreychek

Oh oops :-)

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

Sun, 06/07/2009 - 07:26 (Reply to #15)
andreychek

Oh oops :-)

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

Sun, 06/07/2009 - 07:26 (Reply to #16)
tauvix

I did this by adding the following to my Apache configuration for those domains that required it:

ServerAlias mail.domain.tld
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail\.domain\.tld [NC]
RewriteRule ^(.*) http://www.domain.tld/horde [L,R]

You go to "Configure Website" and then "Edit Directives" and you can pretty much cut and paste those lines :)

Tue, 07/08/2008 - 09:39
andreychek

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 :-)
-Eric

Tue, 07/08/2008 - 12:05 (Reply to #18)
Tito

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.

Sun, 06/07/2009 - 07:26 (Reply to #19)
Tito

Here is what the Directives now looks like:

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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail.your_domain.com$ [NC]
RewriteRule ^(.*) http://mail.your_domain.com/horde
<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"
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>

Tue, 07/08/2008 - 12:24
Tito

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

Tue, 07/08/2008 - 12:30 (Reply to #21)
Tito

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

Tue, 07/08/2008 - 12:31 (Reply to #22)
Tito

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

Topic locked