Pages resolve at different URLs (different capitalizations)

Have you moved servers recently? In years past, Windows servers always treated them differently than on unix servers. Barring that, you can edit your .htaccess file to convert all URLs to lowercase. Here’s a guide editing depending if you have access to httpd.conf file or not; https://www.rewriteguide.com/apache-enforce-lower-case-urls/ As suggested by @Rup, a canonical URL should … Read more

Add a simple php code snippet to redirect a single wordpress url to another

Alright, so I found the solution, it was a simple change in the request object class variable: function redirect_workaround( $request ){ if( $request->request === ‘myspecialurl’ ) { $latest = new WP_Query( array( ‘category_name’ => ‘myspecialcategory’, ‘posts_per_page’ => 1 ) ); if( $latest->have_posts() ){ wp_redirect( get_permalink( $latest->post->ID ) ); exit; } } } add_action( ‘parse_request’, ‘redirect_workaround’ … Read more

Post Migration Site Migration Redirects All Known Solutions Attempted

Can you check the wp-config.php file and make sure it’s not being set by the WP_HOME and/or the WP_SITEURL constants? If you set the WP_HOME and WP_SITEURL constants in the wp-config.php file to webinar.example.test, but have the home and siteurl options in the wp_options table set to staging.webinar.example.org, then running the wp option get siteurl … Read more

How to redirect to a page after submitting form data?

Form handling needs to happen in functions.php (or equivalent) so that it triggers before headers are sent. Here is the how I achieved redirection after form submit: add_action(‘init’, ‘redirectAfterSubmit’); function redirectAfterSubmit() { if (isset($_POST[“submit”])) { insert_row(); wp_redirect( “/thank-you”, 301 ); die(); } } function insert_row(){ // form handing here }

How to create a redirect to another domain like safe redirect manager from php

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

How to Create Custom Route to a page in WordPress

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