Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

.htaccess rewrite/redirect problem (case is changing)

Posted on 2007-03-26
5
Medium Priority
?
177 Views
Last Modified: 2010-03-04
I have a website (Apache 1.3.37 on Linux) which has four domains pointed to it (olddomain1.com, olddomain2.com, olddomain3.com and newdomain.com).  I am trying to modify the .htaccess file so that whenever someone browses to it using the old domain names they are (permanently) redirected to the same page but using the new domain name.  

For example when someone requests
      http://www.olddomain2.com/Cust/Index.html
they should be redirected (permanently) to
      http://www.newdomain.com/Cust/Index.html

This is what I have in the .htaccess file:

      Options All -Indexes +FollowSymLinks
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^www\.olddomain1\.com$ [NC,OR]
      RewriteCond %{HTTP_HOST} ^olddomain1\.com$ [NC,OR]
      RewriteCond %{HTTP_HOST} ^www\.olddomain2\.com$ [NC,OR]
      RewriteCond %{HTTP_HOST} ^olddomain2\.com$ [NC,OR]
      RewriteCond %{HTTP_HOST} ^www\.olddomain3\.com$ [NC,OR]
      RewriteCond %{HTTP_HOST} ^olddomain3\.com$ [NC,OR]
      RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

My problem is, when I browse to a web page the domain name replacement happens but the path and file name of the page is transformed into lowercase.  Naturally this doesn't work as the web server is case sensitive.

For example, when I browse to:
      http://www.olddomain2.com/Cust/Index.html
I receive:
      http://www.newdomain.com/cust/index.html

Could someone please help me to correct the .htaccess file so that I have permanent redirections from the old domain names but preserves the case of the path and filename of the web pages so that they display?

Thank you for your time.
0
Comment
Question by:twixt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
JamesCssl earned 1500 total points
ID: 18797695
Try taking out the OR option of the last RewriteCond
0
 

Author Comment

by:twixt
ID: 18797817
Thanks for your comment.  I did try it but it didn't help.
0
 
LVL 11

Expert Comment

by:JamesCssl
ID: 18797992
I don't see anything in your code that would cause this.  I am using almost the same code for my site, and it keeps the Capitalization when redirecting.
0
 

Author Comment

by:twixt
ID: 18798013
Thanks for your time.  I found an answer in another forum.  The last RewriteCond must not have an [OR] at the end.  Now it seems to work.  Why it should affect the capitalisation I have no idea.  

Someone did alert me to an Apache bug that sounds similar but the bug report says that that bug is only on Windows systems and has been fixed in Apache 2. (http://issues.apache.org/bugzilla/show_bug.cgi?id=23460)

Thanks
0
 

Author Comment

by:twixt
ID: 18804682
>>I found an answer in another forum.

If you are interested: http://www.webmasterworld.com/apache/3293896.htm
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question