?
Solved

How to use mod_rewrite to redirect a URL

Posted on 2014-12-22
8
Medium Priority
?
137 Views
Last Modified: 2014-12-23
I'm trying to find the best way of accomplishing the following:

I have 2 separate web servers, let's call them abc.com and xyz.com.

The server hosting xyz.com is being decommissioned, but there are still active links pointing to it that my customers may continue to use.

Some of the customer links point directly to a perl script with embedded variables, something like this:
https://www.xyz.com/perl/scriptname.pl?var1=1&var2=1

Once I point the xyz.com domain to the server hosting abc.com, I'd like the above URL to be redirected to:
https://www.abc.com/perl/scriptname.pl?var1=1&var2=1

It makes no difference to me whether the end users sees the change in domain name, but I don't want them to get an SSL warning or error.

Is the best way to handle this to use a rewrite rule, an alias, or some other method? Please be as specific as possible with rewrite rules -- my skills are beginner in using mod_rewrite.

Thanks!
0
Comment
Question by:datastarstar
[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
  • 4
  • 4
8 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40513534
Copy everything to the new server - i.e. the old domain
Update the DNS
When the DNS has propogated (upto 48 hours) you can disable the old server and initiate an htaccess on the new server to redirect the old domain to the new domain

But if the old sites ssl cert is expiring then it won't work once it has expired, so you would need to ensure you update it while there may still be links out there.
0
 

Author Comment

by:datastarstar
ID: 40513698
The SSL cert on the old server is still valid -- can I just move that to the new server or does it have to be reissued? And is it possible to have certificates for both domain names in the same crt file?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40513716
You can just move everything.

And is it possible to have certificates for both domain names in the same crt file?
No, each cert needs to be seperate
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:datastarstar
ID: 40513813
Ok, I'm a little confused about this part. I will have no need to segregate the two sites on the new server. I was planning to just point the old domain (xyz.com) to the same IP of the server hosting abc.com.  Can I use a ServerAlias in my apache config in the same virtualhost for xyz.com? How then would I specify the location of separate SSL certificate files?

I'm thinking my virtualhost directive would look something like this:
<VirtualHost xxx.xxx.xxx.xxx:443>
    ServerName abc.com
    ServerAlias xyz.com
    SSLEngine on
    SSLCertificateFile       /etc/httpd/conf/ssl/abc.crt
    SSLCertificateKeyFile    /etc/httpd/conf/ssl/ssl.key
</VirtualHost>
0
 
LVL 58

Expert Comment

by:Gary
ID: 40513826
Ok you can point both domains to the same document root, then in your htaccess setup the redirect condition based on the old domain name
But you can't have one cert for two different domains which is where you are stuck since you are using SSL for the site.
0
 

Author Comment

by:datastarstar
ID: 40514720
What if I pointed xyz to a different IP on the new box and and had a virtualhost section for xyz that used the same document root as abc but pointed to a different ssl certificate? Would that work?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40514893
That's what I was saying above.
0
 

Author Comment

by:datastarstar
ID: 40514965
Got it -- thanks for your help!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

719 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