Modify rewrite rule that strips .html from urls to ad trailing slash

kk,

Despite my aversion to using a TLD (even yours - easier for my testing to duplicate the domain name without WWW and without .com … like your .dev), I see nothing wrong with what you have.

Therefore, I still recommend that you look at where you’d told WP it was located (D:/xampp/htdocs/site.dev/ should be the DocumentRoot) - I’ll bet it’s not it (yet)).

We’re sneaking up on it!

Regards,

DK

DK,

Isn’t that why I need the RewriteBase in the .htaccess, to tell WP where it is located? Because this only happens when RewriteBase is removed and a redirect happens. Everything else with WP and the permalinks for post/pages works just fine.

But still, RewriteBase or not, RewriteRule ^(.+).html(/.+)$ $1$2 [R=301,L] only removes embedded .html and not the .html at the end. Exact same conditions but using RewriteRule ^([^.]+).html([^.]*) $1$2 [R=301,L] rewrites both embedded and ending .html. Wouldn’t that imply that it is the RewriteRule rather then my virtual host config?

Best regards,
A

kk,

If memory serves (I may be losing it … :scream: ), you must configure WP to get it to work properly. The mod_rewrite, remember, is optional (with their wrappers) so WP relies on its configuration file. As I said earlier, though, it’s been quite a while since I’ve setup in a WP website (for a client).

Okay, I thought you always had something (specifially a / followed by anything) after .html. If that’s not true, simply add a ? after the second atom (the (/.+)$ to make it (./.+)?$ - I added the end anchors to help you find the atom).

Regards,

DK

DK,

That would be to add the correct urls in for domain root and WP install dir, but that is correctly done and WP is working properly, its only when RewriteBase is removed and a rewrite accures that this weird redirect happens.

Oh sorry, no the embedded .html is always followed by a /, but then there is the ending .html and that is followed by nothing.

But yeah! That was it, now both embedded and ending .html gets redirected properly! :smiley:

Best regards,
A

kk,

Horray!

Well, if it works with the RewriteBase telling Apache to use the DocumentRoot (while in the DocumentRoot), who’s to argue. Sounds ridiculous but, “if it ain’t broke, don’t fix it.”

Regards,

DK

DK,

Once again, thanks for all the time, inputs and effort, and if I’m not back soon screaming in panic over all my lost rankings and PR… take care and until next time!

Best regards,
A

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.