0

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

Art Badger
  • 310
  • 1
  • 7
Tar get
  • 1
  • 1

1 Answers1

0

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]
Art Badger
  • 310
  • 1
  • 7
  • I just added that on my htaccess file and still did not work. I want this page and every other pages like this to redirect from : http://www.albnews.al/lendohet-valdet-rama/ to http://www.albnews.al/lendohet-valdet-rama.html – Tar get Dec 11 '14 at 18:01
  • small error, I removed the extra slash, try the code now, it should work. Also clear your browser cache, close your browser, repoen browser, clear cache again, then try it. It should work. Also check out this other question: http://stackoverflow.com/questions/10604643/add-html-extension-to-files-in-one-directory-only – Art Badger Dec 11 '14 at 18:09
  • After testing everything out it didn t work. I saw the answer on the other post but even adding content on code didn t work. Any other idea? thanks – Tar get Dec 11 '14 at 19:34