Blackbams Blog
development – digital arts – internet
Knowledge is free. No one may take possession of it.
While using WordPress on IIS 7 we were confronted with the problem that post loops without results or 404 pages on IIS where redirecting to the ugly default 404 pages of IIS instead of leading us to the WordPress ones. The most obvious possibility to solve this problem is to change the IIS server configuration. Anyway I discovered that this 404 page redirection happens not till than WordPress starts sending its headers and only if there is no output until this event. So there is quite a funny hack to solve this problem – just send the XML-declaration (or anything else, like an empty string with whitespace) when the WordPress send_headers-action is performed, and the 404 pages will always be the WordPress ones.
add_action('send_headers','preventIIS404',999);
function preventIIS404() {
echo('');
}
Just be sure that you do not need to have any header()-redirections after this by plugins or your theme, because this will lead you to “Headers already sent”-errors.
Dieser Eintrag wurde am 12. June 2011 um 16:16 in der Kategorie WordPress, WP Scripts veröffentlicht. You can book the comments for this article RSS 2.0. Feedback, discussion, commendation and critics are welcome: Write a comment or trackback.
No comments yet
Kommentare abonnieren (RSS) or URL Trackback
Leave a comment: