redirect to 404 page
Almost every hosting provider provide this redirection feature in their admin panel, so you can redirect from there. Alternatively, you can use Page Links To plugin.
Almost every hosting provider provide this redirection feature in their admin panel, so you can redirect from there. Alternatively, you can use Page Links To plugin.
By looking over the code of Safe Redirect Manager, we were able to find what we were looking for. We just needed to create an instance of the redirect post type using code similar to this: $post_args = array( ‘post_type’ => ‘redirect_rule’, ‘post_status’ => $sanitized_post_status, ‘post_author’ => 1, ‘menu_order’ => $sanitized_menu_order, ); $post_id = wp_insert_post( … Read more
To set up a custom route in WordPress, you can use the add_rewrite_rule() function. This function allows you to specify a regular expression (regex) pattern for matching URLs and a corresponding rewrite rule for redirecting matching URLs to the desired destination. Below is an example of how you could use this function to create a … Read more
Redirect to Homepage if URL contains string
If you are hosting on a LAMP environment. You can put this redirect in .htaccess file. RedirectRule must be placed before the WordPress generate rules. So that, your rule get executed before WordPress take it through. RewriteRule will look something like this <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # if WP installed in a folder … Read more
Redirects and forced 404 are not that good for SEO, also might hurt user experience. I recommend that you take this approach (if you’re code savvy): <?php //Your page template //Check if user have permission if ( $permission ) { //All your page/post content here } //Else user have no permission -> show him something … Read more
Something like this should do it: add_action(‘wp’, ‘custom_user_redirect’); function custom_user_redirect() { if (is_user_logged_in()) {return;} // array of page IDs OR slugs to allow access to $skippages = array(11, 23, 12); foreach ($pages as $page) { if (is_page($page)) {return;} } wp_safe_redirect(wp_login_url()); }
Redirect if a user has not written a post
Answering this here to save others time if they run into a similar issue. Clarity on this issue provided in this answer on SO Regular expression redirects only work when all the information about the new location can be derived from the URL for the old location. That isn’t the case here. You have new … Read more
Forcing header cache control in 404 pages