tonyf
tonyf

Reputation: 35587

Redirect URL to another URL

I have the following page that a user can go to by where this URL exists within their email.

For example: http://www.abc.example/yourdetails.html

My question is, I have now been told that this whole web app is being moved to a new domain, i.e.

http://www.xyz.example/yourdetails.html

Assume there are no issues with accessing the two domains within the network (intranet), how can I redirect the user when clicking on a link in an email that is no longer the correct link to actually call the new URL:

http://www.abc.example/yourdetails.html

I basically want to ensure that even though users have old URLs in their emails, when clicking on this old URL, actually hop over to new correct URL.

Upvotes: 3

Views: 13588

Answers (9)

Christian Smorra
Christian Smorra

Reputation: 1754

<script>
window.location='http://newurl.com/page.html'
</script>

or even better (just one snippet for all pages)

<script>
window.location='http://newurl.com'+window.location.pathname
</script>

Upvotes: 0

aniri
aniri

Reputation: 1831

Or using a php script on the old location:

<?php
    header( 'Location: http://new_page.html' ) ;
?>

Upvotes: 0

Im0rtality
Im0rtality

Reputation: 3533

in PHP: < ?php header("Location: http://www.abc.com/yourdetails.html"); ?>

Upvotes: 0

Sebs
Sebs

Reputation: 3058

By Apache's mod_rewrite module. You could create something like (on the old domain):

RewriteRule ^yourdetails.html$ http://www.xyz.com/yourdetails.html [R=301,L]

Upvotes: 1

CEich
CEich

Reputation: 33474

If you're on an apache server, this sounds like a job for mod_rewrite.

try http://corz.org/serv/tricks/htaccess2.php http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html

Upvotes: 0

Scott Saunders
Scott Saunders

Reputation: 30414

  1. If the site is not changing structure, you can point the xyz.com domain to abc.com in DNS.

  2. I think you can configure apache, using modrewrite, to rewrite calls from the old domain to the new one. You might not be able to do this if the domains are on different servers.

  3. You can edit the page at http://www.xyz.com/yourdetails.html and add a redirect header (and maybe an explanation) to redirect to the new page.

Upvotes: 4

Jose Diaz
Jose Diaz

Reputation: 5398

A URL by definition points to a single web resource, what you can do is configure your web server to map multiple URLs to the same web resource.

Please refer to this for more info, on how to do this on Apache.

Upvotes: 0

Ash Burlaczenko
Ash Burlaczenko

Reputation: 25475

Add this meta tag to the top of your page on the abc domain.

<META HTTP-EQUIV="refresh" CONTENT="0;URL=http://www.xyz.com/yourdetails.html">

Hope this helps.

Upvotes: 0

Jay
Jay

Reputation: 1356

Until you can send out new emails with the proper domain you will want to use a 301 permanent redirect on the xyz.com domain. You can use an .htaccess file to do this. Google for information specific to your webserver. This Site seems to have good information specific to Apache.

Upvotes: 1

Related Questions