This is unrelated to Excel, but a neat trick I discovered while moving a website to a new domain. Hope it will help some people out there!
- Copy the .htaccess file from the new site to the old website that redirects all clean urls to the index.php file. In this case I just used WordPress’ default .htaccess file, which does the job. (I was moving a WordPress blog.)
- Start a new file index.php, and put in the following code in the old site:
<? if(isset($_SERVER['REQUEST_URI'])) $page=$_SERVER['REQUEST_URI']; if($page!='/') $page='/'.$page; else $page=''; Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://newsitename.com".$page); ?=
Basically what we did here is retrieve the part of the URL after the domain name and the slash (/), so if a user requested “http://www.oldsite.com/about-us”, $_SERVER[‘REQUEST_URI’] would get be “about-us”. There’s a if statement that checks if a / is already included (sometimes it does). If not, it will add one to the URL. All that’s left to do here is just get the header to redirect it to the new domain, and attach $_SERVER[‘REQUEST_URI’] behind it.