404 redirect based on url

I would use the wp hook, which fires right after the request has been parsed and queried: function wpse_199869_wp( $wp ) { if ( ! is_admin() && is_404() && preg_match( ‘/^bh-job/’, $wp->request ) ) { wp_redirect( home_url( user_trailingslashit( ‘jobs’ ) ) ); exit; } } add_action( ‘wp’, ‘wpse_199869_wp’ ); We make sure it’s a 404, … Read more

Multisite 404 page

The easiest way is to check for get_current_blog_id(); and adjust your 404 template based on the current blog id. An other option is creating a child theme for every site and adding different page-404 templates.

Direct form to a custom page template

A helpful clue would be to look at the URL in the address bar of your 404 page. A reliable approach for form action in WP looks like the snippet below. <form method=”post” id=”thisform” action=”<?php bloginfo(‘url’); >/dbsearch/”> I would create your page in WP, ensure the page slug is ‘dbsearch’ as this determines your permalink … Read more

Redirect to parent page if child does not exist

If you want to do this in your .htaccess file to ensure an early redirect, the method is as follows. First check if the page does not exist using the rewrite condition: RewriteCond %{REQUEST_FILENAME} !-f Next comes the rewrite rule for the page that does not exist RewriteRule ^/au/location1/(.*)$ http://example.com/au/location1/ [L] Putting this all together: … Read more

Link to WP-CONTENT not working

I have experience with this issue and find solution maybe work with your problem Check Wp-Content Permission change to 775 Delete or rename your .htaccess like .bkphtaccess Setting permalinks as default and save Turn back permalinks as your custom permalink and save If allowed new .htaccess will create automatic, if not copy text at the … Read more

How do I redirect a permalink for a Draft post to a custom 404 page?

Here is what I came up with. Seems to be working. If anyone has suggestions for improvement, I’m all ears: // Redirect links to future posts to Coming Soon page. add_action(‘wp’,’redirect_coming_soon_posts’, 0); function redirect_coming_soon_posts(){ global $wpdb; if ($wpdb->last_result[0]->post_status == “future” && $wpdb->last_result[0]->post_date_gmt != ‘0000-00-00 00:00:00’ && ! is_admin() ): session_start(); $_SESSION[‘next_post_id’] = $wpdb->last_result[0]->ID; wp_redirect( ‘/coming-soon’, … Read more