Redirect all sites to version with HTTPS

NiteWave

Administrator
#2
using rewrite rule in virtual host or .htaccess

Code:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/%{REQUEST_URI [R,L]
 
Last edited by a moderator:

NiteWave

Administrator
#4
if you use WHM and easy apache 4, can create a file(e.g., https.conf) under /etc/apache2/conf.d/userdata/
best added one line at the beginning:
RewriteEngine On
in addition to above 2 lines.
 
Last edited by a moderator:

Pong

Administrator
Staff member
#6
For LSWS native, You can add the above rewrite to new virtual host template in rewrite section, everytime when you create new virtual host, it will set.

For the existing virtual hosts, you can write a script to add the rewrite to .htaccess for all virtual hosts.
 

qtwrk

Well-Known Member
#9
Hi,

seems xenfore has a problem when use to quote a rewrite rule that contains special symbols will be dropped.

but good to know it works now :)

best regards
 
#10
By following this same reasoning, how can I redirect ALL sites from one specific URL to another? I'm trying to follow the following syntax but it just does not work.

Apache config:
RewriteEngine On
RewriteRule ^oi$ /oiiiiiii/ [R=301,L]
 

Pong

Administrator
Staff member
#11
I can see the following rule works fine:
Apache config:
RewriteRule ^oi/(.*) https://%{HTTP_HOST}/oiiiiiii/$1 [R=301,L]
example.com/oi/info.php will rewrite to example.com/oiiiiiii/info.php without a problem.
 
Last edited by a moderator:
#12
Not works for me!

This is my file /etc/apache2/conf.d/userdata/cache.conf

Apache config:
RewriteEngine On
RewriteRule ^wp-admin/admin.php?page=wpfastestcacheoptions/(.*) https://%{HTTP_HOST}/oiiiiiii/$1 [R=301,L]
I need redirect https://example.com/wp-admin/admin.php?page=wpfastestcacheoptions to https//mycompany.website/my-custom-page
 
Last edited by a moderator:

Pong

Administrator
Staff member
#13
1. I don't believe you can do query string like that. You may have to place query string in the rewrite condition
2. if your rules are in apache configuration, you will need to use an absolute path. not the same rules as in .htacesss.
You could use something similar to the following(not test yet, but you can run your test.
Apache config:
RewriteCond %{QUERY_STRING} ^page=wpfastestcacheoptions/(.*)
RewriteRule /wp-admin/admin.php https://%{HTTP_HOST}/oiiiiiii/%1
3. This is not something specific to LiteSpeed, all about writing rewrite rules. make sure your test your rewrite rules with Apache. LiteSpeed should just work if they work with apache.
 
Last edited by a moderator:
#14
1. I don't believe you can do query string like that. You may have to place query string in the rewrite condition
Why I need redirect pages of caching plugins redirect to something like this: https://en.support.wordpress.com/incompatible-plugins/
2. if your rules are in apache configuration, you will need to use an absolute path. not the same rules as in .htacesss.
You could use something similar to the following(not test yet, but you can run your test.
I'll try this and get you back!
3. This is not something specific to LiteSpeed, all about writing rewrite rules. make sure your test your rewrite rules with Apache. LiteSpeed should just work if they work with apache.
Great explanation, thanks!
 
Last edited by a moderator:

Pong

Administrator
Staff member
#16
Did you test with apache? If not working with apache, then need to tweek the rule until it is working with Apache. Since you are using cpanel/whm, switching between apache and LSWS is very easy
 

Pong

Administrator
Staff member
#18
assuming you mean example.com = mycompany.website, the same thing.

If the above is what you need, you can try the following in /etc/apache2/conf.d/userdata/redirect.conf

Code:
RewriteCond %{QUERY_STRING} ^page=wpfastestcacheoptions
RewriteRule /wp-admin/admin.php https://%{HTTP_HOST}/custom.php? [R=301,L]
The above rule should remove your trailing query string and direct /wp-admin/admin.php to custom.php page as far as query string starting with page=wpfastestcacheoptions

https://mycompany.website/wp-admin/admin.php?page=wpfastestcacheoptions should redirect to https://mycompany.website/custom.php

If this is not your case, please provide an example in details.
 
Last edited:
#19
Ok I'll explain a little better ...

I want to prevent my clients from using other cache plugins other than Litespeed Cache. So if you try to access this WP Fastest Cache page they will be redirected to that URL: https://centraldocliente.felintonetwork.com/knowledgebase/3/How-to-improve-the-cache-of-site-site. html

Here I explain what Litespeed Cache is and how to use it.

I could use the cpanel feature that installs on all websites the litespeed cache, however if it has an active cache plugin it simply ignores it. Which is terrible! =(
 

Pong

Administrator
Staff member
#20
Thank you for the clarification. Look like a Must-Use plugin which forbidden other cache plugins being installed by pulling the forbidden list dynamically could be an idea/solution for your need, but I am not sure when such MU plugin can be available.

Anyway, in term of rewrite, can try the following:

RewriteCond %{QUERY_STRING} ^page=wpfastestcacheoptions
RewriteRule /wp-admin/admin.php https://centraldocliente.felintonetwork.com/knowledgebase/3/How-to-improve-the-cache-of-site-site.html [R=301,L]
 
Top