Solved

How to use mod_rewrite to redirect a URL

Posted on 2014-12-22
8
123 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
  • 4
  • 4
8 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 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
 

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Question has a verified solution.

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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now