Changing hosts without editing 450 absolute links

Have about 450 absolute links in various HTML newsletters with “sitemason.com/files” in the path. We are dumping SiteMason as a host and don’t want to manually change all of those links to “ourdomainname.com/files”. After we switch, is there a PHP way to automatically redirect people who click one of those old sitemason links? Any help much appreciated.

There are two ways that should help you out:

PHP redirect:
[php]

<?php header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: http://www.new-url.com/files/" ); exit(); ?>

[/php]

.htaccess redirect:
[php]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.olddomain.com/files$[OR]
RewriteCond %{HTTP_HOST} ^olddomain.com/files$
RewriteRule ^(.*)$ http://www.newdomain.com/files$1 [R=301,L][/php]

Please let me know if this helps you out!

I cannot thank you enough. You have saved me hours of work. Thanks so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service