How To Integrate non-WordPress pages in WordPress and Avoid 404 Errors

So  you want to use your old PHP files, but with your WordPress installation/theme. So the Codex tells you that this can be done, and you just have to include the following in your PHP files:

<?php
/* Short and sweet */
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>

This would make it possible to use all the WordPress functions and include the header, footer, widget area etc. When tested with Chrome developer tools, I noticed that it returned a 404 File not found in the headers. Fortunately I came across the solution from a link on the same Codex page, instead of the above code, use the following:

<?php
define('WP_USE_THEMES', false);
require('p/wp-config.php');
$wp->init();
$wp->parse_request();
$wp->query_posts();
$wp->register_globals();
$wp->send_headers();
?>

This should return a 200 Status OK header instead and everything should be okay.

To include the header and footer you can use the following code/method:

<?php
define('WP_USE_THEMES', false);
require('p/wp-config.php');
$wp->init();
$wp->parse_request();
$wp->query_posts();
$wp->register_globals();
$wp->send_headers();
get_header();
?>
The content goes here...
<?php get_sidebar(); ?>
<?php get_footer(); ?>

That should do the work :)