wordpress how to force redirection from all pages

2019-08-29 13:10发布

问题:

I have a one-page wordpress site. It uses pages and posts but is all programatically included in the core template. I don't want users to ever accidentally access a single posts (even though it's unlikely that would ever happen). I would prefer to not have to use a 404 template either so it would be great to redirect EVERY page to the home page. Is this easily done without interfering with the default .htaccess rules?

回答1:

Try using this plugin. It allows redirection of all URLs.



回答2:

Add this line of code to your htaccess file:

redirect 301 / http://www.yoursiteurl.com/

Replace "yoursiteurl" with your actual domain.



回答3:

I ended up using this plugin and redirecting each page manually, thus leaving irrelevant pages to throw a 404 error. It's not what I wanted but in the end it's best practice.