How to force redirects

#1
I use Cloudflare.
In rules I have this rule:

Code:
somesite.com/*
Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.somesite.com/$1)
It forces a URL to prepend "www", and return that URL in the browser. Has worked well for years on a Nginx server.

However, using OLS, the prepend is stripped.

In Virtual Hosts Configuration:
- the VIRTUAL HOST NAME is set as "somesite.com".
- the DOMAIN NAME is set to "www.somesite.com"

Restarted, doesn't work.

What am I doing wrong?
 

Cold-Egg

Administrator
#2
Hi,

Use the following rewrite rule in the .htaccess file should do the job,

Code:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.somesite.come/$1 [R=301,L]
 
Top