301 Header help needed - it's not redirecting the browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

301 Header help needed - it's not redirecting the browser

Post by simonmlewis »

Code: Select all

header("Location: http://site.local/subcateg/$rowredir->catid/$categreplace/$rowredir->subid/$subcategreplace/",TRUE,301);
If someone finds a product that is paused from consumer view, I want to redirect them to the next available subcategory.

I have captured both the prodID and subID, and now wanting to 301 them to the subID. The above isn't working. All that happens is they are taken to the product page and shown a message (from the product.inc file) to say it is no longer available.

I don't get any errors, but they aren't taken away either.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: 301 Header help needed - it's not redirecting the browse

Post by Celauran »

You've checked that the redirect URL is correct? Checked that the header call comes before all browser output?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: 301 Header help needed - it's not redirecting the browse

Post by simonmlewis »

My bad - the bloomin query to generate it wasn't pulling the data up correct.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply