Hi.
The people who manage the sites I run sometimes change categories names, sometimes even update product IDs, and because of that, you do get URLs cached by Google (and others) that become redundant.
All these sites run from their own index.php template. So how do you identify, perhaps in index.php if the productID queried exists, and if not, take them to perhaps a 404 Error page that Google sees as a 404 or a 301?
We can manually change and do 301s in htaccess via a CSV export and just point them all to a page. But be better if it did this dynamically.
Web sites must do this kind of thing all the time, specially with sites that customers "run" (ebay, amazon, Facebook etc).
Index looks for the ID, it doesn't exist, so goes to a error.inc file. But Google doesn't see that file as a 404 or 301 direction. So how do you do that?
Can you query a database via htaccess and if the ID doesn't exist, do a 301??
404 missing pages - how to control dynamically?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
404 missing pages - how to control dynamically?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
phpdeveloper1
- Forum Newbie
- Posts: 19
- Joined: Tue Aug 12, 2014 6:13 am
- Location: Chennai, India
Re: 404 missing pages - how to control dynamically?
For 301, how do you want the index php script to redirect ? Based on what parameters?
Last edited by phpdeveloper1 on Tue Aug 12, 2014 6:58 am, edited 1 time in total.
Chris, Php Developer and Programmer,
https://www.phpfreelanceprogrammer.com/
https://www.phpfreelanceprogrammer.com/
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: 404 missing pages - how to control dynamically?
For 301, I want to query the database based on the the URL's $id, and if the $id is not in the system, to do a 301 to /error.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
phpdeveloper1
- Forum Newbie
- Posts: 19
- Joined: Tue Aug 12, 2014 6:13 am
- Location: Chennai, India
Re: 404 missing pages - how to control dynamically?
Yes a line can be automatically added in .htaccess to do a 301 rewrite/redirectsimonmlewis wrote:For 301, I want to query the database based on the the URL's $id, and if the $id is not in the system, to do a 301 to /error.
so next time when someone accesses the page the will be redirected to not found page
But for google I'm not sure how it will work
Alternatively you can try outputting RAW header
header('HTTP/1.0 404 Not Found');
and see whether it considers the page as 404
Chris, Php Developer and Programmer,
https://www.phpfreelanceprogrammer.com/
https://www.phpfreelanceprogrammer.com/
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: 404 missing pages - how to control dynamically?
But how will the 301 work dynamically?
I know how to do a 301. But I need it to query the ID of the page it is crawling, and then do a 301.
I know how to do a 301. But I need it to query the ID of the page it is crawling, and then do a 301.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.