Osclass Support Forums

Osclass theme support => Free themes => Topic started by: Miller on September 18, 2018, 08:29:35 PM

Title: htaccess redirect
Post by: Miller on September 18, 2018, 08:29:35 PM
Hi mbthemes ,
My website chain redirecting

Domain.com — http://domain.com — https://domain.com —https://www.domain.com

RewriteEngine On
# ensure www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

I want.

Domain.com — https://www.domain.com
Title: Re: htaccess redirect
Post by: MB Themes on September 19, 2018, 08:57:45 AM
@Miller
I am not skilled with these htaccess things. Check google.
Anyway I do not think https part is correct.
Title: Re: htaccess redirect
Post by: Ajit Sahane on June 02, 2023, 07:48:38 AM
Add this code on TOP of htaccess.

To rewrite all URLs to the https://www. version of your URL - paste this at the top of your htaccess file.

Code: [Select]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
To rewrite all URLs to the https:// (non www) version of your URL - paste this at the top of your htaccess file.

Code: [Select]
RewriteEngine On
# match any URL with www and rewrite it to https without the www
RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]
# match urls that are non https (without the www)
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
& check here live -  https://www.serpworx.com/check-301-redirects/?url=domain.com         -  enter only domain name

score must 100  then all OK -