Forum Moderators: open

Message Too Old, No Replies

301 Redirect

Where should it go?

         

stu2

3:55 am on Apr 27, 2006 (gmt 0)

10+ Year Member



I want to put a 301 Redirect into my web page. Firstly, how to write this? Secondly, where should it go if I still want my javascript traffic analyzer still to work?

tedster

4:04 am on Apr 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A 301 redirect is not html -- it depends on the server where you are hosted and/or what kind of scripting you can use.

ASP and PHP both can do page redirects. And Microsoft IIS and Apache Web Server have even more options for you. All of these technologies have their own forums here, and once you know which options you have access to, those specific forums would be the best place for help if you still need it.

In terms of the javascript traffic analyzer, there can be no universal answer -- it would depend on how the specific application works. Whoever provides the solution would be the best place for you to turm, once you know how you plan to do the 301.

stu2

5:35 am on Apr 27, 2006 (gmt 0)

10+ Year Member



I've found 2 solutions, but don't know if they are doing 301 Redirects:-

Using meta tags...

<meta http-equiv="REFRESH" content="0; URL=http://www.example.com">

and using javascript...

<script language="JavaScript"><!--
setTimeout('Redirect()',0);
function Redirect()
{
location.href = 'http://www.example.com';
}
// --></script>

or this...

<SCRIPT LANGUAGE="JavaScript">
<!--
window.location="http://www.example.com/";
// -->
</script>

tedster

5:47 am on Apr 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Although these approaches change what page the browser displays, neither one is a 301 [Permanent] redirect. The 0 second meta refresh is actually dangerous to use, since it became a low-level spam technique years ago. And spiders will not execute JavaScript. It's a client-side language, executed on the user's machine and not a server-side script or setting.

You need the server to answer back to the user agent's url request with a 301 http header.

On the page PHP or ASP scripting -- and Apache Server or IIS Server settings. Those are your choices for a 301.

stu2

6:43 am on Apr 27, 2006 (gmt 0)

10+ Year Member



Thanks tedster. I know how to do it with PHP and .htaccess.

I don't really care about spiders at all, only real people. The reason I wanted to put this redirect on the page itself was because I'm also planning run a javascript traffic analyzer on the page so I can see where the traffic is coming from before forwarding it to my domains landing page where they're parked, because my preferred parking service doesn't provide sufficent traffic stats. There will be no content on the page, just traffic analyzer code and a redirect. I'm kinda scrambling in the dark, and it feels like I'm reinventing the wheel.

The reason I asked where to place the code on the page was, if I do a redirect, does the page stop executing, or will it execute the javascript traffic analyzer below the redirect. Or do I have to put the redirect below the traffic analyzer script?

Can you explain what you mean by dangerous? Do browsers (or anything) object to this technique? So you would suggest the window.location technique in javascript?

Finally, I want to avoid forwarding the hit to my parking page because then all my hits to my pages would come from my ip address. It has to be so that I tell the browser to go to my parking page directly. Do these techniques do this? I only mentioned 301 Redirects primarily because I know that is what it does. Tells the browser to go elsewhere. The traffic origin is not compromised.