Non-existent page returns code 200

That’s not what’s happening, when you visit /contacts–/ it doesn’t return a 200 code, but instead it returns a 301 redirect code. The browser then follows this redirect and heads to /contact and it’s /contact that returns 200 code. This is because /contact is the canonical URL of that page, and WordPress redirects to canonical … Read more

Redirect a page id url but not the page slug

Try using the pre_handle_404 hook instead: add_filter( ‘pre_handle_404’, ‘wpse_383506’, 10, 2 ); function wpse_383506( $preempt, $wp_query ) { if ( ! empty( $_GET[‘page_id’] ) && ‘342’ === $_GET[‘page_id’] ) { // Throw a 404 error. $wp_query->set_404(); // And prevent redirect to the page permalink (pretty URL). remove_action( ‘template_redirect’, ‘redirect_canonical’ ); } return $preempt; // always … Read more

WordPress 404 on Subdomain

You don’t appear to have allowed .htaccess overrides in the <VirtualHost *:443> container, so .htaccess is effectively disabled. Without .htaccess you’ll naturally get 404s for anything other than the homepage if you are using “pretty” permalinks. (.htaccess is not required for requests to the homepage, since index.php is served by mod_dir which is no doubt … Read more

Form in WordPress : 404

You’re probably using an input field that contains name=”name”. A lot of generic words are used by WordPress itself (incl. name, so a best practise is to always prefix_ your fields, like name=”prefix_name”.

What causes an Unexpected HTTP Error within install plugins?

You can use the following code to dump the HTTP Api response, will help you figure out the cause of error. function dump_http_api_response($response, $type=””, $transport=null ) { if ( $type == “response” ) var_dump ( $response ); } add_action(‘http_api_debug’, ‘dump_http_api_response’, 1, 3); Example Output: object(WP_Error)#15 (2) { [“errors”]=> array(1) { [“http_request_failed”]=> array(1) { [0]=> string(41) … Read more

What does do_action(‘admin_init’); does actually?

What it does: It offers an action handler, a moment in run time to execute other functions. So it is a hook for plugins and core functions. Removing all hooked functions or changing the core file will break WordPress. If your plugin fails to work with it – fix the plugin.