HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=4)
-   -   apache2 RewriteCond questions (http://www.howtoforge.com/forums/showthread.php?t=30545)

MisterVlad 23rd January 2009 06:20

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

Miguel 23rd January 2009 07:44

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.

MisterVlad 23rd January 2009 07:56

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?

Miguel 23rd January 2009 08:02

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

...

Miguel 23rd January 2009 08:07

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]

MisterVlad 23rd January 2009 19:34

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

Miguel 23rd January 2009 19:44

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.


All times are GMT +2. The time now is 01:09.

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