Saturday, 15 March 2014

PHP - header() redirect: Firebug logs 404 - why? -



PHP - header() redirect: Firebug logs 404 - why? -

i using php redirect in 1 of projects. this:

header( 'location: http://domain.net/?cig=warn&onum=' . $onum . '&cnum=' . $cnum . '&c=' . $c . '#form' );

so see, it's normal utilize of php's header() function variables included in url. it's working, testing page firebug, error in console:

"networkerror: 404 not found - http://domain.net/?cig=warn&onum=12&cnum=73&c=ui#form"

is there wrong way or firebug beingness picky because of parameters , anchor?

since page lives within wordpress environment, must forcefulness 200 status code manually setting before headers sent (using wordpress status_header() function):

<?php // must appear before output sent! status_header(200); ?>

you'll have pull in wordpress functions @ this, obviously. problem wordpress intercepting request before page has chance process it. cannot locate "page" , sets 404 response code, gets sent out.

when i've had pull in wordpress functions in past, i've done including these 2 lines on page:

define('wp_use_themes', false); require_once("/path/to/my/site/wp-blog-header.php");

now, said, pages i've done in past have had same , sense ones in wordpress installation. there may improve way pull in functions alone; you'd have consult wordpress documentation find out (i don't know if there is). how might question wordpress stackexchange site.

php redirect header http-headers firebug

No comments:

Post a Comment