LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-23-2012, 12:55 PM   #1
moyorakkhi
Member
 
Registered: Jan 2011
Location: Dhaka
Posts: 80

Rep: Reputation: 1
Page redirect in Apache with mod_rewrite


Hello,

In our mail server there are multiple virtual email domain hosted. User can use webmail.example.com (this is the first apache virtualhost) to check mail or they can use mail.THEIR-DOMAIN.com. If the put mail.THEIR-DOMAIN.com apache shows the webmail.example.com as it is the first virtualhost and mail.THEIR-DOMAIN.com doesn't exist. Recently we imposed https for webmail.example.com and added this mod_rewrite rule:
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
But now users not getting the default webmail page as they were getting before. How can we redirect all request coming to the URL "mail.ANY-DOMAIN.com" to "https://webmail.example.com"? I've tried the following but it didn't work:

Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (mail.*) https://webmail.example.com
 
Old 03-23-2012, 02:17 PM   #2
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
# Add the rule
RewriteCond %{HTTPS} on
RewriteRule (mail.*) https://webmail.example.com
 
Old 03-23-2012, 03:13 PM   #3
moyorakkhi
Member
 
Registered: Jan 2011
Location: Dhaka
Posts: 80

Original Poster
Rep: Reputation: 1
Hi Sydney,

Thanks for your response. It's not working actually. I've tried adding it on both webmail.example.com virtualhost entry as well as in httpd.com file. Traffic not redirecting to https://webmail.example.com.

Thanks again!
 
Old 03-23-2012, 03:16 PM   #4
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
I hope not to send you on a goose chase but I always have on in lower case.
 
Old 03-23-2012, 03:49 PM   #5
moyorakkhi
Member
 
Registered: Jan 2011
Location: Dhaka
Posts: 80

Original Poster
Rep: Reputation: 1
Yeah. I also have "on" in lower case. But it's not happening.
 
Old 03-23-2012, 04:28 PM   #6
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(mail.*)$ https://webmail.example.com [R]

Last edited by Sydney; 03-23-2012 at 04:53 PM.
 
Old 03-23-2012, 05:07 PM   #7
moyorakkhi
Member
 
Registered: Jan 2011
Location: Dhaka
Posts: 80

Original Poster
Rep: Reputation: 1
Thanks for your help Sydney. I Got it working with the following:

Code:
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail. [NC]
RewriteRule ^(.*)$ https://webmail.example.com/$1 [L,R=301]
</VirtualHost>
I tried with your code as well. But didn't worked unfortunately.
 
Old 03-23-2012, 05:11 PM   #8
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
Quote:
Originally Posted by moyorakkhi View Post
Code:
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail. [NC]
RewriteRule ^(.*)$ https://webmail.example.com/$1 [L,R=301]
</VirtualHost>
I am glad you got it resolved! Thanks for posting your solution.
 
  


Reply

Tags
apache, mod_rewrite



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Redirect Apache (mod_rewrite) from subdomain to https directory (vhost) accessthecloud Linux - Newbie 2 05-02-2011 07:07 AM
[SOLVED] How to redirect from one page to another using apache and still retain original url? peterson.julia Linux - Server 4 04-04-2011 03:54 PM
Apache redirect for non existing page cooljai Linux - Server 1 11-03-2008 09:00 AM
mod_rewrite: redirect depending on subdomain mysql_connect Linux - Server 1 08-01-2007 06:23 AM
Apache default page redirect Harry Seldon Linux - Enterprise 7 05-12-2006 08:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration