Applying ‘middleware’ to a url before redirecting? Does WP have built in mechanism for this?
Applying ‘middleware’ to a url before redirecting? Does WP have built in mechanism for this?
Applying ‘middleware’ to a url before redirecting? Does WP have built in mechanism for this?
function mmk_pending_review_redirect(){ $user = wp_get_current_user(); if(get_post_status ( get_the_id() ) != ‘publish’) if (is_user_logged_in() && !in_array( ‘administrator’, (array) $user->roles ) && !is_author() ) { wp_redirect( “https://example.com/under-approval”); exit; }else{ wp_redirect( “https://example.com/under-approval”) ); exit; } } } add_action(‘template_redirect’, ‘mmk_pending_review_redirect’); explanation: redirect non-admin users to custom URL if they are not author of the current post where status is … Read more
So this had been a constant issue for me but finally i got this working, thanks to this blog post. http://www.velvetblues.com/web-development-blog/turn-off-wordpress-homepage-url-redirection/ It seems like adding this in the functions.php file for the enabled theme works. Pasting here for anyone who may be facing a similar issue. remove_filter(‘template_redirect’,’redirect_canonical’); I restarted the httpd and the php-fpm service, … Read more
This should work for what you’re looking to achieve; add_action( ‘template_redirect’, ‘redirect_to_specific_page’ ); function redirect_to_specific_page() { if ( ! is_user_logged_in() && ! is_page(‘one_time_login’) ) { wp_redirect( ‘domain.com/sub’, 301 ); exit; } } This should be added to your theme (or child theme) functions.php file
htaccess redirect not working for wp-admin/edit in site using proxy
302 Redirect is showing in the audit but links are opening separately
date based redirect in wordpress
WordPress no permission redirection to a popup
It might be that WordPress is just redirecting to the version with trailing slash. /cart => /cart/ /shop => /shop/ I’m having trouble, finding a good canonical source why WP is doing this. The fact is, that most web frameworks (I worked with) will force trailing slashes on their routes (that are not directed at … Read more
This is intended behaviour for WordPress install and will use the value set in the siteurl entry in the options table. What you want to achieve will probably have to be done with Nginx or Apache using Rewrites, or proxy_pass (for Nginx) or RewriteRule and ProxyPass (Apache)