Topic: Switching from ASP to PHP... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=27705" title="Pages that link to Topic: Switching from ASP to PHP... (Page 1 of 1)" rel="nofollow" >Topic: Switching from ASP to PHP... <span class="small">(Page 1 of 1)</span>\

 
DaveFA
Bipolar (III) Inmate

From: USA
Insane since: Feb 2004

IP logged posted posted 03-29-2006 20:54 Edit Quote

I run a semi-popular (6,000+ uniques/day) blog that I've had up for almost seven years now, and I've done a number of redesigns. I've been using ASP since the site was started, but almost all of my work now is done in PHP and C#.NET.

So, the time has come for a big redesign, but I also want to switch over to php while I'm at this juncture. Recoding the site, that's easy. Making sure that the search engines don't reset my relevancy after the switch from asp to php (therefore rendering the indexed links dead and removing them from the search engines) - that's hard.

What I'm asking is if anyone has switched their site(s) from one language to another, and found a good way to redirect users (and spiders) to go from the previous format to the new format. I realize I can do this somewhat efficiently using .htaccess, but I'd like to hear ideas.

Oh, almost forgot - I'm switching hosts with this move, from FlareHosting.com to Dreamhost (where I've already got an account), so, when I switch over ASP will be completely unsupported.

-----------------------------------
-Dave

Maker of stuff, user of things
-----------------------------------

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

IP logged posted posted 03-30-2006 06:51 Edit Quote

well... when we switched this forum over to a completly different one, we used a combination of .htaccess and php-find-what-content-the-user-was-looking-for-in-a-big-array scripts that reported the correct 302: Document moved permamently (or was it 301? Look it up) response header.

Google had all it's links updated within a couple of weeks - and the old ones still work to this day.

DaveFA
Bipolar (III) Inmate

From: USA
Insane since: Feb 2004

IP logged posted posted 03-30-2006 16:52 Edit Quote

Any chance you could post an example of the "php-find-what-content-the-user-was-looking-for-in-a-big-array" and the changes to your .htaccess file? I'd be forever grateful.

Thanks.

-----------------------------------
-Dave

Maker of stuff, user of things
-----------------------------------

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

IP logged posted posted 03-30-2006 18:28 Edit Quote

well... the relevant part of the .htaccess reads like this

code:
RewriteEngine On

RewriteRule ^(/Forum)([0-9]+)(/HTML/)([0-9]+)(.html) /lookup/asylumforum.php?forum=$1&thread=$2 [L]
RewriteRule ^(/Archives/Archive-)([0-9]+)(/HTML/)(.+) /lookup/asylumarchive.php?archive=$2&thread=$4 [L]



so you see, I had the advantage of having regexable urls..

Now, the lookup php is nothing special... it basically has a serialized array at it's disposale that I built during the import of the old text file based data into the database saying 'that text file went into that row (id) in the database'

code:
<?php
function notFound()
{
	header("Location: /search");
	echo "404 - Not Found - you'll be redirected shortly"; // NN4 requires that we output something...	
	die();
}

if (!(is_numeric(@$_GET['archive']) && isset($_GET["thread"])))
	notFound();

$strFilename = dirname(__FILE__) . '/archive.'. $_GET['archive']. '.dat';
if (file_exists($strFilename))
{
	if ($fh = fopen($strFilename,'rb'))
	{
		$t = fread($fh,filesize($strFilename));
		fclose($fh);
		$threads = unserialize($t);		
		$threadName = $_GET["thread"]. '.cgi';
		if (!isset($threads[$threadName]))
			notFound();
		else
		{
			header("HTTP/1.1 301 Moved Permanently");
		header("Location: /{$threads[$threadName]}");
		header("Connection: close");		
		die();
		}
			
	}
	else
		notFound();
}
notFound();
?>




Of course, you could also replace the 404 handler, and do some funky stuff there to refind whatever the user was looking for, and then issue a 301...

so long,

->Tyberius Prime



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu