*

Miller

  • ****
  • 141 posts
htaccess redirect
« on: September 18, 2018, 08:29:35 PM »
Hi mbthemes ,
My website chain redirecting

Domain.com — http://domain.comhttps://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

*

MB Themes

Re: htaccess redirect
« Reply #1 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.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Ajit Sahane

  • ****
  • 156 posts
  • https://bestclassifiedsusa.com
Re: htaccess redirect
« Reply #2 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 -