Simple page redirection by user role or by page

July 3rd, 2020 / by kingjman09

#php #wordpress

If you are working on a client site and do not want to install another plugin, then you can manually paste the wordpress action hook in your theme’s functions.php file. This are just a quick and fully working ways to redirect certain pages based on your needs.

Creating a 301 Redirect using the WordPress .htaccess file.
Locate the .htaccess file, at the root directory of your WordPress site. Note that if you can’t locate the file, it’s hidden and you’ll need to force the FTP to show your hidden files.

RewriteEngine On
// Sample page redirect code:
Redirect 301 /an-old-post-url/ /a-new-post-url/

//If you need to redirect the whole website, use this sample code:
Redirect 301 / http://www.yournewwebsitehere.com
If you have suggestions and corrections please feel free to drop it in the comments section.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × two =

close
Kingj Maningo blessed

Thanks for taking the time to reach out. How can I help you?