#1  
Old 23rd January 2009, 06:20
MisterVlad MisterVlad is offline
Member
 
Join Date: Jun 2007
Location: Windsor, Ontario, CANADA
Posts: 61
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to MisterVlad Send a message via Skype™ to MisterVlad
Default apache2 RewriteCond questions

Ok... what i am looking for, is to setup squirrelmail a little easier/better.

I have a bunch of domains on my server, all of them are working fine right now. but they all have to goto http://www.theirdomainname.com/squirrlemail

what i would LOVE to have happen, is the point http://webmail.theirdomainname.com or http://mail.theirdomainname.com goto the squirrelmail login page.

What i would like not to happen (it is a personal thing) is just have that URL at the top, and it JUST show http://webmail (or mail).theirdomainname.com without anything after. currently the /squirrelmail redirects and puts /squirrelmail/src/login.php in the address bar.


Is this easy to do on a global basis? or am I going to have to add that to every domain that i host?

thanks
Reply With Quote
Sponsored Links
  #2  
Old 23rd January 2009, 07:44
Miguel Miguel is offline
HowtoForge Supporter
 
Join Date: Sep 2007
Location: Maasmechelen - Belgium
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Default Rewrite condition

MisterVlad,

this should do the trick. I use to have gallery.mydomain.tld rather than mydomain.tld/gallery

RewriteEngine On
RewriteBase /
# Rewrite foo subdomain requests to foo subdirectory
RewriteCond %{HTTP_HOST} ^squirrel\.yourdomain\.tld
RewriteCond %{REQUEST_URI} !^/squirrel/
RewriteRule (.*) /squirrel/$1 [L]
Put this in the .htaccess in the root of yourdomain.tld.

Please note that the above works with the directory name. So if squirrelmail is installed in squirrel or squirrelmail you will need to use squirrel respectively squirrelmail. Renaming the directory to webmail or mail does the trick.

The is also a rule to redirect requests for yourdomain.tld/squirrel to squirrel.yourdomain.tld but I can't find for the moment.

Have fun.
Reply With Quote
  #3  
Old 23rd January 2009, 07:56
MisterVlad MisterVlad is offline
Member
 
Join Date: Jun 2007
Location: Windsor, Ontario, CANADA
Posts: 61
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to MisterVlad Send a message via Skype™ to MisterVlad
Default

ok, you say to put that in teh .htaccess in my root domain, but...

what if someone goes to webmail.domain2.com, does it have to be in there as well??

what i need, is:
webmail.domain1.com
webmail.domain2.com
webmail.domain3.com
and/or
domain1.com/webmail
domain2.com/webmail
domain3.com/webmail

all to point to the webmail... but i would like to have it read in the addressbar as webmail.{whicheverdomainnametheyareon}.com/

does that make sense on what i am askign?
Reply With Quote
  #4  
Old 23rd January 2009, 08:02
Miguel Miguel is offline
HowtoForge Supporter
 
Join Date: Sep 2007
Location: Maasmechelen - Belgium
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Default Domain .htaccess

You need to put this in each domain's .htaccess to work.

So you need it i domain1.tld, domain2.tld, ...

The syntax of the rewrite condition is specific for each domain:

RewriteCond %{HTTP_HOST} ^mail\.domain1\.tld

RewriteCond %{HTTP_HOST} ^squirrel\.domain2\.tld

...
Reply With Quote
  #5  
Old 23rd January 2009, 08:07
Miguel Miguel is offline
HowtoForge Supporter
 
Join Date: Sep 2007
Location: Maasmechelen - Belgium
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Default More specific:

In domain1 .htaccess

RewriteEngine On
RewriteBase /
# Rewrite foo subdomain requests to foo subdirectory
RewriteCond %{HTTP_HOST} ^squirrel\.domain1\.tld
RewriteCond %{REQUEST_URI} !^/squirrel/
RewriteRule (.*) /squirrel/$1 [L]

In domain2 .htaccess

RewriteEngine On
RewriteBase /
# Rewrite foo subdomain requests to foo subdirectory
RewriteCond %{HTTP_HOST} ^squirrel\.domain2\.tld
RewriteCond %{REQUEST_URI} !^/squirrel/
RewriteRule (.*) /squirrel/$1 [L]
Reply With Quote
  #6  
Old 23rd January 2009, 19:34
MisterVlad MisterVlad is offline
Member
 
Join Date: Jun 2007
Location: Windsor, Ontario, CANADA
Posts: 61
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to MisterVlad Send a message via Skype™ to MisterVlad
Default

There's no way around it? that's the only way is to put it in everyone's .htaccess?


I thought that there would be a way to do this within the apache .conf files (or sites-enabled)?
Reply With Quote
  #7  
Old 23rd January 2009, 19:44
Miguel Miguel is offline
HowtoForge Supporter
 
Join Date: Sep 2007
Location: Maasmechelen - Belgium
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default

You could try putting it in rewrite.conf, but I never did.

To do so you need to disable rewrite and re-enable rewrite to enable the .conf file.

First of course write the .conf file. For ubuntu/debian it should be in /etc/apache2/mods-available/rewrite.conf

RewriteEngine On
RewriteBase /
# Rewrite foo subdomain requests to foo subdirectory
RewriteCond %{HTTP_HOST} ^squirrel\.domain1\.tld
RewriteCond %{HTTP_HOST} ^squirrel\.domain2\.tld
RewriteCond %{HTTP_HOST} ^squirrel\.domain3\.tld
RewriteCond %{REQUEST_URI} !^/squirrel/
RewriteRule (.*) /squirrel/$1 [L]

Given that the subdirectory has the same name for all domains this might work.

You can of course put it in the apache vhost conf of each domain. Than you don't need to put it in the .htaccess, but in each apache vhost configuration.

My best bet is to still put it in the root folder of each site to make it work.
Reply With Quote
Reply

Bookmarks

Tags
apache, apache2, rewritecond, squirrlemail, webmail

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess and RewriteEngine On Boon-Dog-Danny Installation/Configuration 8 31st December 2008 09:28
apache & mod_rewrite problems kingkunt Server Operation 9 9th July 2008 06:36
Custom error pages with pictures ? Djamu Installation/Configuration 4 23rd September 2007 17:42
can't make work joomla + sef + .htaccess bochenn General 9 4th April 2007 13:47
CentOS and .htaccess rlhesson Installation/Configuration 5 31st March 2007 14:00


All times are GMT +2. The time now is 00:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.