Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic - jumpt to URL

Status
Not open for further replies.

Grimblam

Programmer
Sep 27, 2004
9
0
0
GB
This is a really basic question!
I've been using header("location: place.html"); to jump to a URL from PHP script. Is this the best way to do it and is there an alternative?

I put my pages onto Lycos and they don't seem to jump when they get to that part of the script!

Cheers,
Andy
 
Does Lycos run your pages inside a frame, or add crap to the top of your page, or something? header() cannot follow any other output from the page, or else it gets ignored (because page headers have already been sent to the browser). When you actually are viewing the page that is supposed to redirect but doesn't, do a View Source and see what's happening at the very top of the page. They probably insert a lot of code that would show their popups and that is probably stopping your header() from working.

Marc
 
Thanks HMarcBower

It does add a frame actually so that sounds like the problem. Do you have any suggestions on what I can do to jump to a URL, with this in mind?

Cheers,
Andy
 
Some javascript might be able to do it from within the frame... I just have to remember the syntax... :)

I think it's

<BODY onLoad="location.href='
I'm not sure if that's right, but that is the gist of it. You can do a search and look up a proper syntax for location.href if it doesn't cooperate.

Marc
 
there are two other ways off the top of my head:

this one works great in IE, but sometimes NN is pretty picky and it doesn't work (this goes between the head tags):

<meta http-equiv="refresh" content="0;url=place.htm">

and going on the post above mine, javascript can be performed anywhere in the document:

<script>window.location='place.htm';</script>

Here's another interesting resource on 301 Redirects (to cover your tracks if you permanently move a page):
[URL unfurl="true"]http://www.22i.co.uk/web-design-tips/301-redirects-permanently-moved.php[/url]


 
Thanks a lot for the help guys, i'll give them a try.

 
A php header(URL) sends a 302 response to the user agent. SE crawlers do not take any action to a 302 as it is a Temporary Redirect and they DO NOT follow redirects only update the database URIs. as a 307/302 does not require a change to the URI no action is taken.

Javscript redirects are not followed or actioned as SE crawlers are not JS enabled and can be viewed with some suspicion.

the only safe way to redirect SEs are with a 301 permanent redirect.

thread on redirects in the SEO forum thread828-983652

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top