+2  A: 

You want to use a URL rewrite

RewriteEngine On
RewriteRule ^(.*)\.html$ $1
Zurahn
I gave this a shot by adding it to below the code I included above, but I'm worried that there will be an issue with the variables, since the original htaccess file includes: RewriteRule ^index\.php$ - [L]
chris m
What do you mean by "issue with the variables" exactly? If you put Zurahn's code above your WordPress rule definitions, it should do what you need without any issue (assuming you don't serve up any actual .html files).
Tim Stone
Tim, I originally added Zurahn's code beneath the WordPress code. I added it to the top, and it still doesn't work. It's annoying, yes, and I would normally do this is with a find/replace in phpMyAdmin, but there are a few posts that link to external websites whose URLs include HTML files.I added what the code looks like right now to the original post.
chris m
Ah, no, you're right. It's because WordPress must use `REQUEST_URI` to determine the request path, which is unaffected by an internal redirection. You can obviously externally redirect, but let me think if there's a way to do it internally.
Tim Stone
Much appreciated thus far, Tim. If you think of anything for me to try, post it in a new comment so I can give you props.
chris m
+1  A: 

This should do it. It will rewrite a request to site.com/category/whatever.html to site.com/category/whatever. it shouldn't be dependent upon the requested file existing.

    <Directory /var/www/category>
        RewriteEngine on
        RewriteRule (.*)\.html$ /category/$1
    </Directory>

This is the format for apache2.conf or virtual host files. Not sure if you use the command in .htaccess. It's best to take care of it in the server conf, if you can, as that is only parsed once, on server startup, and htaccess is parsed on each request.

Alex JL
The site is hosted on Dreamhost, so I don't have access to the configuration files. I'm worried that there will be an issue with the variables, since the original htaccess file includes: RewriteRule ^index\.php$ - [L]
chris m
Variables? There aren't any variables involved in an htaccess file. They $ means end of line, and $1 is a captures from a regular expression. They only have meaning within that one line.
Alex JL
Okay, I understand that finally. I updated what my .htaccess looks like right now, and it still results in a 404 when I visit http://the-site.com/category/the-webpage.html
chris m
What is it being rewritten to - does it 404 saying the-webpage.html is not found, or another file name?
Alex JL
The URL stays the same (the-site.com/category/the-webpage.html), and WordPress sends me to the 404 page I designed.
chris m
+5  A: 

This will work to force an external redirection to your new URLs, but this may not be ideal for your situation. I'm still trying to think if there's a way to keep the redirection internal and update the variable that WordPress uses to determine which page to serve up, but so far I haven't thought of anything that would work.

Entire .htaccess:

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

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Tim Stone
That did it, Tim! I'll update the original post for future visitors with the same issue. Thank you very, very much.
chris m
A 301 redirect is okay, since the new URLs are permanent. Thanks again.
chris m
Awesome, and no problem, glad it's working like you wanted.
Tim Stone
Absolutely, and thank you again. It was one of those things, while designing/developing a site, that sticks out in the back of your mind telling you "I have no idea how I'm going to make that work." You, my friend, are a savior. Thank you a hundred times over.
chris m