Question about repurposing WordPress 404 handler

Here is the tested code, you can use it as a mu-plugin: <?php /** * Filters whether to short-circuit default header status handling. * * Returning a non-false value from the filter will short-circuit the handling * and return early. * * @param bool $preempt Whether to short-circuit default header status handling. Default false. * … Read more

Unwanted redirect in admin area

I solved it with the help of a colleagues of mine by adding the following lines into wp-config.php: $_SERVER[‘HTTP_HOST’] = $_SERVER[‘HTTP_X_FORWARDED_HOST’]; $_SERVER[‘REQUEST_URI’] = ‘/stuff/wordpress’ . $_SERVER[‘REQUEST_URI’]; $_SERVER[‘SCRIPT_NAME’] = ‘/stuff/wordpress’ . $_SERVER[‘SCRIPT_NAME’]; $_SERVER[‘PHP_SELF’] = ‘/stuff/wordpress’ . $_SERVER[‘PHP_SELF’]; $_SERVER[‘REMOTE_ADDR’] = $_SERVER[‘HTTP_X_FORWARDED_FOR’];

Serve apache 404 for missing assets rather then wp 404 template WP_Rewrites

This very helpful page is unfortunately kind of burried on the codex: Basically mod_rewrite_rules hook will do the trick. function faster_htaccess_rules( $rules ){ $faster_rules = <<<EOD \n # BEGIN faster Apache 404 rules RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp)$ – [R=404,L] #Use instead for network sites #RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp)$ – [nocase,redirect=404,last] # END faster Apache … Read more

Detect 404 before headers are sent

Use a later action hook You cannot use Conditional Tags before the posts_selection hook has run (as per the codex), which happens right after pre_get_posts and quite a bit after init. Hence, would it not be easier to set the cookie at a later stage of the request, rather than attempting to detect the 404 … Read more

Changing Site Address (URL) causes 404

Go to phpMyAdmin and select the database for the website. Go to the “wp_options” table and edit the first option (option_name: siteurl) from “http://www.example.com/wordpress” to “http://www.example.com/somethingelse“. In the same “wp_options” table, look for “option_name: home” and change the URL there too. Now, rename your current .htaccess file to .htaccess_old and create a new blank .htaccess … Read more