I have all my pages in the pages module.
I’d like to direct to a 404 page if the requested url is not in the pages module.
Does anyone know “how to” do this?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
July 17, 2008 6:54pm
Subscribe [2]#1 / Jul 17, 2008 6:54pm
I have all my pages in the pages module.
I’d like to direct to a 404 page if the requested url is not in the pages module.
Does anyone know “how to” do this?
#2 / Jul 17, 2008 7:01pm
Maybe a combination of the show_pages parameter and the if no_results conditional?
#3 / Jul 17, 2008 7:09pm
That might work for most situations, but in my case I want to embed the 404 template before the weblog tag is called.
A php solution would be preferred, maybe a query to the db.
#4 / Jul 17, 2008 7:44pm
Is the built-in 404 preference not working for you?
You can use a simple database query and if no match then return a header like this:
<?php header("HTTP/1.0 404 Not Found"); ?>
But I would use the built-in support if at all possible.
#5 / Jul 17, 2008 7:48pm
I didn’t think the built-in 404 preference works with the pages module. I’m not sure how to access the built in 404 preference from the admin to test it.
#6 / Jul 17, 2008 8:09pm
#7 / Jul 17, 2008 8:48pm
Ah there it is! It works great!
THanks