1

After changing the Wordpress Permalink structure, I was using RewriteMatch in the .htaccess file to create 301 redirects for all of the pages.

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/)(.+)$ https://mywebsite.com/$4

I switched to OpenLiteSpeed recently and found that this no longer worked. Someone confirmed OLS ignores the RedirectMatch rule and advised switching to RewriteRule, so I used an htaccess tester tool and put the following together.

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/) $4 [QSA,L]

I don't have much experience with writing rules, but the tool showed the correct output. After adding it to my .htaccess file however, it still doesn't work. I've restarted OLS but no changes.

I'm trying to figure out if there is something wrong with the rule (i.e. something incompatible with litespeed), or if this is related to the OLS web server?

Aidan Knight
  • 253
  • 2
  • 11

1 Answers1

2

Please try add this rule at top of your .htaccess

RewriteRule ([0-9]{4})\/([0-9]{2})\/(.*) https://example.com/$3 [R=301,L]

restart OLS after you added it.

qtwrk
  • 329
  • 2
  • 7
  • That worked beautifully! Do I not need to have RewriteEngine On and the +FollowSymLinks flag set? Seems to work without them but would just like to make sure. Thank you very much :) – Aidan Knight Aug 14 '20 at 16:24
  • 1
    actually , engine is not needed , and option is not even working on OLS at all ... OLS only reads `rewriterule` and `rewritecond` , anything other is dropped. – qtwrk Aug 14 '20 at 23:53