开发者

404 page with htaccess

If i have a rewrite rule setup to get any name that is not a file and display the page-layout-select.php

How would I set a 404 if the page returns nothing as if I type anything (a page name that does not exist) it still loads the page-layout-select but without the content (because it doesn't exist)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ page-layout-select.php?slug=$1 [L,QSA]

Any help with this would b开发者_运维知识库e great

Thanks


The way I do it (although I'm sure there are better ways) is to have a php include; if your normal pages are effectively:

page-layout-select.php?page=news
page-layout-select.php?page=home

etc, where news, home are included (or written dynamically from a db), then your .htaccess can have

ErrorDocument 404 /page-layout-select.php?page=404error

where 404error is also just a simple include. In page-layout-select.php, check if the content you want to show exists, and if not, include 404error instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜