Redirect Directory to a subdomain with case-insesitivity

ranjeetm

New Member
Messages
13
Reaction score
0
Points
0
Hello Friends I have tried hard before posting but was not able to find a solution to my problem...If someone can help me I will be very great full ....


I want to redirect
Code:
http://www.domain.com/mail to http://mail.domain.com
(A CNAME entry) with case-insensitivity (also with or without WWW)

i.e
I also want
Code:
http://www.domain.com/Mail or mAil to redirect to http://mail.domain.com
that also with or without WWW

for e.g.
Code:
http://www.domain.com/mail --> http://mail.domain.com
Code:
http://www.domain.com/Mail --> http://mail.domain.com
Code:
http://www.domain.com/mAil --> http://mail.domain.com
Code:
http://domain.com/mail --> http://mail.domain.com
Code:
http://domain.com/Mail -->http://mail.domain.com
Code:
http://domain.com/mAil --> http://mail.domain.com

where
Code:
http://mail.domain.com
is a CNAME record I haven't added a directory of this name in my root directory...

Thanks in Advance.....
 
Last edited:

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
I am pretty sure that a CNAME record is not the best way to go. I would use .htaccess to redirect people who access any variation of /mail to mail., and there should be a CNAME record that covers a user appending a www. to the domain by removing it.

Exmaple: www.exmaple.com/mail

CNAME Record (step 1):
www.example.com/mail -> example.com/mail

.HTACCESS (step 2)
example.com/mail -> mail.example.com
http://www.webweaver.nu/html-tips/web-redirection.shtml

I would rather you read the article for yourself and learn something :)
 
Last edited:

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
htaccess Redirect and Rewrite will NOT work on server "boru"
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
.htaccess should be functioning on all of the servers and if they are not then there is something odd going on. Anyway, here is an example .htaccess you could use:
Code:
RewriteEngine on
RewriteRule ^mail(/.*)?$ "http://mail.yourdomain.com$1" [R=301,L,NC]
This code will take into account all case-derivatives of 'mail', so 'Mail' and 'MAil' etc will all be redirected to http://mail.yourdomain.com . This will also redirect subdirectories of the mail folder to subdirectories in the mail subdomain, so sending a request for http://yourdomain.com/mail/folder1/folder2/file.php will redirect to http://mail.yourdomian.com/folder1/folder2/file.php .
I think this covers everything that you required in your request, to use this simply create a file called '.htaccess' in the root of the domain you are redirecting FROM (So put it in the folder where you put files for http://yourdomain.com) and put that code in that file.
 

ranjeetm

New Member
Messages
13
Reaction score
0
Points
0
Thanks will implement ... will let you know if it works or not.....
 
Top