Solved

How to use mod_rewrite to redirect a URL

Posted on 2014-12-22
8
127 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

751 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