Some weeks ago I decided to move this blog from elis.nu to blog.elis.nu, becouse I wanted to use the domainname elis.nu for other things… Without breaking compatibility… :)
There is three things you have to do when you do this:
- Change domainname in the adminpanel
- Have the new name pointed
- Update the settings in the webserver
The order of one and two doesn’t matter that much. But it’s important to do one before three, else it will break the adminlogin and other stuff that depends on the URL configured.
Then we come to the forth step I took, to not break any inlinks or RSS-Readers that follows the blog… That’s much more interesting.
One choice I did when I created this blog was wise, I have the linkstructure “/index.php/YYYY/MM/postname/”, this makes it easier in my case… No need for a rewrite on the new page… So I just wrote a URI parser in PHP, just a few lines and a 301 redirect for all urls that requests anything longer than just “/index.php”.
Now I just hope that all RSS-Readers follows this redirect… I know that webbrowsers do…
Code used for redirect:
<?php if(strlen($_SERVER['PATH_INFO']) > 1) { $location = 'http://blog.elis.nu/index.php'.$_SERVER['PATH_INFO']; header('HTTP/1.1 301 Moved Permanently'); header('Location: '.$location); die('<html> <head> <title>Moved</title> </head> <body> <h1>Moved</h1> <p>This page has moved to <a href="'.$location.'">'.$location.'</a>.</p> </body> </html>'); } else { ?> <!-- Put new website here --> <?php }
Very simple, does the job. And please check elis.nu out, leave comments here :)