Hi everyone.
I installed CyberPanel and moved my site. I was using RedirectMatch with my links that changed.
But with OLS rewrite rules I cant use this. Is not there RedirectMatch on OLS? Or may I do some changes on codes.
I was using this codes for redirecting main extension and all sub extensions with any cpanel hostings.
RedirectMatch abc/(.+) https://your-domain.com/def/$1 [R=301,L]
RedirectMatch abc/$ https://your-domain.com/def/ [R=301,L]
With this codes I could redirect "abc link" to "def" and automatically all "abc sub extensions" to "def sub extensions".
For example:
/abc => /def
/abc/a => /def/a
/abc/a/b => /def/a/b
But with CyberPanel and OLS RedirectMatch is not working for me. I always take search console errors with 404 about changed and not redirected links.
On OpenLiteSpeed forum I saw a RewriteRule redirect like this:
(RewriteRule phpinfo.php /2/phpinfo.php) but this is not working, too.
Google Bots started to go back to the old links - extensions. So redirects are not working no longer.
Thanks.
Comments
This will work
CyberPanel
Blog
Thanks for reply but it is not working Usman Nasir.
Create ticket.
CyberPanel
Blog
Hi Usman Nasir.
I created a ticket and ID: P6M-L7D-WSPR
You need to put these rules below LSCache block and before WordPress rules.
CyberPanel
Blog
So thanks Usman Nasir.
You saved me from a big trouble. Did you do any other change? I used this codes and they did not work before, as far as I remember.
Also I added this codes at the bottom of the htacces, by mistake. But they worked, too
Have not made any other changes.
CyberPanel
Blog
Edit: The Rewriterule codes should be added like Usman Nasir says, after LSCache and before WordPress rules. Otherwise the redirect is not working.
Thanks.
I know this discussion is a bit stale, but since it's the only one I found while searching - it's possible this is what others get to see.
I tried the above method but it isn't working for me. I found that using RewriteRule ^/?listing/(.*)$ https://www.def.com/listing/$1 [R=301,L] is more correct with openlitespeed from here
https://openlitespeed.org/kb/migrate-apache-rewrite-rules-to-openlitespeed/
Unfortunately, redirect still isn't working. What am I missing?
**The main Site is MU subdomain**
Before (At the past it worked but now not)
RewriteRule /aaaaa/(.+) https://your-domain.com/bbbbb/$1 [R=301,L]
RewriteRule /aaaaa/$ https://your-domain.com/bbbbb/ [R=301,L]
After (At the past not tried but now working)
RewriteRule ^/?aaaaa/(.+) https://your-domain.com/bbbbb/$1 [R=301,L]
RewriteRule ^/?aaaaa/$ https://your-domain.com/bbbbb/ [R=301,L]
Or this form (If not works above two option you can try this, I do not try this form at all)
RewriteRule ^/?aaaaa/(.*)$ https://your-domain.com/bbbbb/$1 [R=301,L]
NOTE: Do not forget to reload OpenLiteSpeed and LiteSpeed services from your CyberPanel/ServerStatus tab after any change.
<IfModule mod_rewrite.c>
(rules here)
</IfModule>
... In order to work?
I haven't make this work in an .hatcess file (inside public_html folder, wordpress)
Also. Can the redirection be to an external URL? As usual? Because I'm sort of pissed of this isn't working. So many hours with this, and yet here we are...