The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. February 12, 2012, 04:28:26 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Handy 301/302 redirect reference  (Read 2262 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« on: June 29, 2009, 05:28:11 PM »

Tooling about, I happened on this page, and particularly for beginners I think it'd be a good thing to bookmark.

http://www.webconfs.com/how-to-redirect-a-webpage.php

Shows how to do a 301/302 in
  • ColdFusion
  • PHP
  • ASP
  • ASP.net
  • JSP (Java)
  • CGI PERL
  • Ruby on Rails
  • and a couple great .htaccess examples.

Happy 301ing!
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 509


View Profile
« Reply #1 on: June 29, 2009, 06:36:53 PM »

Tooling about, I happened on this page, and particularly for beginners I think it'd be a good thing to bookmark.

http://www.webconfs.com/how-to-redirect-a-webpage.php

Shows how to do a 301/302 in
  • ColdFusion
  • PHP
  • ASP
  • ASP.net
  • JSP (Java)
  • CGI PERL
  • Ruby on Rails
  • and a couple great .htaccess examples.

Happy 301ing!

That's a good reference page.

I see all the examples show how to send the raw server headers, except for
the Perl example which uses cgi.pm.

I have never used that perl module.

Anyways, to send the raw server header for a 301....

#!/usr/bin/perl
print "Status: 301 Moved\r\n", "Location: http://google.com/\r\n\r\n";


OR

#!/usr/bin/perl
print "Status: 301 I AM NOT CLOAKING\r\n", "Location: http://google.com/\r\n\r\n";


Wink



Logged

"Everything that can be counted does not necessarily count; everything that counts cannot necessarily be counted." -- Albert Einstein
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #2 on: June 29, 2009, 07:45:23 PM »

Nice Bomps, thanks!

As a side note, I've never 301d when I've cloaked - always 302d. Any preference for you?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 509


View Profile
« Reply #3 on: June 30, 2009, 12:51:25 AM »

Nice Bomps, thanks!

As a side note, I've never 301d when I've cloaked - always 302d. Any preference for you?

Actually, when I am keeping the visitor on the same domain I don't usually redirect, but
instead just use my perl code to deliver different content.  No particular advantage, just
habit I suppose.

Most of my redirecting nowadays is for spoofed sites, (a one page site that looks innocent
enough for others to approve a link), and in those cases, the SEs get the 301 to my money site.

Bomps
Logged

"Everything that can be counted does not necessarily count; everything that counts cannot necessarily be counted." -- Albert Einstein
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #4 on: June 30, 2009, 07:44:57 AM »

'Spose I should have qualified as shadowing, not cloaking (because I cloak the same way).

Ah, gotcha ... cloaking the 301. Nice.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!