Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My site URL is http://funandfoodcafe.com I changed my Permalink structure to Postname today, and I am using WP 3.5.

All the links on the site redirect to the new structure correctly, but all incoming links, from Google or any other referring sites still go to "http://funandfoodcafe.com/post-name.html" instead of "http://funandfoodcafe.com/post-name/"

The extra .html is causing all incoming links to result in 404 errors. I get heavy referral traffic, so this is really bad, because its almost like my site is down!

Can someone help me resolve this issue please?

Thanks, Mansi

share|improve this question
3  
what did you expect to happen exactly? change it back until you put a solution in place. –  Milo Jan 23 '13 at 23:44
    
how can I redirect all links with .html extension to go to just postname/ e.g: funandfoodcafe.com/melting-crayons.html should actually go to funandfoodcafe.com/melting-crayons –  Mansi Jan 23 '13 at 23:57
    
the simplest solution to this is done via an .htaccess file, not within WordPress. see this question/answer. –  Milo Jan 24 '13 at 0:08

1 Answer 1

In your .htaccess file put:

RewriteCond %{REQUEST_URI} \.html$
RewriteRule (.*).html$ /$1/ [R=301,L]

That should redirect with a "moved permaently" from the .html pages to pages with the endings stripped. It should probably go above your WordPress rules. It should even preserve query strings-- at least it did when I tested it.

share|improve this answer
    
Aah! thanks so much ha_dum, that worked. I needed to add another redirect statement to my .htaccess too, for some other links that were not being redirected by using WP alone, so I added these 3 lines to my .htaccess file: "RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ funandfoodcafe.com/$3 RewriteCond %{REQUEST_URI} \.html$ RewriteRule (.*).html$ /$1/ [R=301,L]" and looks liek its working for now...will test some more and let you know how it goes! –  Mansi Jan 24 '13 at 0:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.