问题
I moved my site to a new host but by accident permalink was changed. First i had a /%postname%.html and after moving to new host it got changed to /%postname%/ . I fixed the permalink and is working fine except when Google crawls my website google search results return 404 error pages.
I tried every redirect plugin and nothing is working. I want to redirect every post that is http://www.website.com/sample-post/ to http://www.website.com/sample-post.html
I can not add every single post because there are around 100k posts.
Any ideas? thanks
回答1:
Firstly you are attempting to treat the symptom, not the problem. This will cause more issues for you in the future.
However, the best way to do what you want is to use rewrite rules in apache's .htaccess file.
Something like this should work. Modify as desired.
# add .html file extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.+)$ /$1.html [L]
来源:https://stackoverflow.com/questions/27429088/redirect-all-posts-on-wordpress