301 Redirect via rewrite_rules_array (not .HTACCESS)
301 Redirect via rewrite_rules_array (not .HTACCESS)
301 Redirect via rewrite_rules_array (not .HTACCESS)
user_register hook fires immediately after a new user is registered. so you have to add action on this hook. You can add below example code in your active theme’s function file. Example : add_action( ‘user_register’, ‘redirect_user_based_on_role’, 10, 1 ); function redirect_user_based_on_role( $user_id ) { // Get the user object. $user = get_userdata( $user_id ); // … Read more
The solution is extremely simple. Just create a rule redirecting all URLs to /specificpage with the position set as 1 (remembering to activate regex for the rule): ^.* And two “do nothing” rules, one for /wp-admin and another one for /specificpage, both with the position set as 0. That’s all.
Yes, WordPress sometimes automatically redirects URLs under certain conditions when it detects changes in the permalink structure or slugs Check Permalink Settings: Go to Settings > Permalinks in your WordPress dashboard. WordPress Redirect Rules in .htaccess file Disable Plugins that Handle Redirects if any activated for WordPress dashboard If you have checked WordPress Core and … Read more
Non-existent URLs/slugs redirect to default Posts page
One page is redirected to home and I don’t understand why
One of the ways to do this is by using mod_rewrite. Open your .htaccess file and add this code before the # BEGIN WordPress line: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^aritcles/(.*)$ /$1 [R=301,NC,L] RewriteRule ^news/(.*)$ /$1 [R=301,NC,L] RewriteRule ^reviews/(.*)$ /$1 [R=301,NC,L] </IfModule>
WordPress Redirects Old Post Url to New Related Post
I had the exact same problem, and I believe that was probably caused because WordPress doesn’t know about the primary category (that is something added by Yoast SEO instead). So is something that in my opinion Yoast SEO should manage, hopefully in next releases they’ll do it. In the meanwhile it looks I’ve smoothly resolved … Read more
You can do it with the “template_redirect” hook. For multisite or simple WordPress. e.g: add_action(‘template_redirect’, function(){ $user = wp_get_current_user(); $userRoles = $user->roles; $url = site_url(); if(!in_array(‘administrator’, $userRoles) && !is_front_page()){ wp_redirect($url); exit; } }); EDIT is_front_page() will work only if “Front page displays” is set. Use is_home() if not. EDIT #2 Accordind with our discuss below, … Read more