How to redirect a page into file?

Recommend and currently use Quick Page/Post Redirect Plugin https://wordpress.org/plugins/quick-pagepost-redirect-plugin/ Request URL Destination URL /page/ http://example.com/uploades/file.pdf

redirecting and showing notice from previous action

opinion: I like ajax interactions for things like this. DELETEs are cheap, fast things to accomplish server side, loading the whole page all over again takes too long. /opinion If you’re going to use redirects and want to display error messages, you have a couple of options. 1. Use the redirect url itself to pass … Read more

What is the right way to redirect all traffic to HTTPS?

Number 1 If you want your website to be ONLY accessible through HTTPS, you will want to add this piece of code to your .htaccess file, replacing your domain’s name: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] </IfModule> This will redirect any visits from non-SSL to SSL version of your website. … Read more

Auto-detect the redirect url from the original url

You can simply write your own function this way: function get_old_link($url) { global $wpdb; // get only url path $parse = parse_url($url); $path = trim($parse[‘path’], “https://wordpress.stackexchange.com/”); // get last part as slug $arr = explode(“https://wordpress.stackexchange.com/”, $path); $slug = end($arr); // find post id by meta_key and meta_value $row = $wpdb->get_row(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key … Read more

Stuck In a Redirect Loop

You also need to check if the user is on that particular page or not. If he is on that page, then there is no need to redirect him/her again. Change your else to this: if(is_user_logged_in() && function_exists(‘pmpro_hasMembershipLevel’) && pmpro_hasMembershipLevel()) { global $current_user; $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); echo ‘Membership Level: ‘ . $current_user->membership_level->name; } else { … Read more

WordPress url incomplete redirects to first article with that name

Stop URL Guessing – Method 1 The first way to stop WordPress from guessing URLs is to use the below code. To do that, open up your theme’s functions.php file. Once opened, copy and paste the below code and reupload the file. remove_filter(‘template_redirect’, ‘redirect_canonical’); That’s all there is to do. From this point forward, WordPress … Read more

Redirect first category archive page to normal page

If you want paginated pages to not redirect, you can check the is_paged() boolean. It will return true if you’re on an archive page greater than page 1 ( the first page of the archive ). So if it returns false, it means we’re on the page you want redirected. function my_page_template_redirect(){ $category_array = array( … Read more