Htaccess vs permalinks vs Wordpress (failing miserably!)


#1

Hi helpful people,

We’re just getting back on our feet after a fraught DIY server switch from GoDaddy – our final snag is a permalink/htaccess issue with WordPress.

Our permalinks are all /post-name.html
Our Google search results link to /post-name/

We want to create an .htaccess file to redirect requests for /post-name/ to /post-name.html so our Google visitors stop getting “page not found”.

We know it can be done because it was working on the previous server – but we lost, or rather forgot, to bring this file with us in the transfer.

We’ve spent 2 days trying every code combination we can find – nothing is having any effect, in any direction. (Tried changing permalinks to /post-name/ and redirecting from .html to that).

The file permission is set to 0644 in DreamHost FTP. And emptying the cache after every upload makes no change. (If those are important details?)

Any help appreciated for 2 “not very tech savvy” but willing and grateful citizens!


#2

Why not just remove the forced .html extension from Admin > Settings > Permalinks ?


#3

Yes but then we have the reverse problem: pages not found if you arrive to a /post-name.html link (via a bookmark, for example). (We’d also have to change all the internal links for a 100+ page site – we’ll do it if we have to, but…).

We don’t care which way the links are structured, just to have the safeguard that, whether a visitor uses A or B URL, they get a real page.

Really appreciate if anyone has some input on getting a code to work. Thank you!


#4

Something like this should redirect the “bookmarkers” to the non-html appended link:

RewriteRule ^index\.php$ - [L]
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

#5

Magic! Something exactly like that, yes! Thank you so much! Really, really appreciate your help.