• I currently have a site wide 301 redirect from http to https which works ok alongside a redirect from non www to www.

    When I type in the url for any other page non https it’ll show the non secure page and not redirect to https version. How to I correct this within .htaccess?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Supposedly this forces https:

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]

    Thread Starter timmer81

    (@timmer81)

    This is my current .htaccess file

    RewriteOptions inherit
    <IfModule LiteSpeed>
    RewriteEngine on
    </IfModule>
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mywebsite.co.uk [NC]
    RewriteRule ^(.*)$ https://www.myswebsiye.co.uk/$1 [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^mywebsite\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mywebsite\.co\.uk$
    RewriteRule ^index\.html$ "https\:\/\/www\.mywebsite\.co\.uk\/" [R=301,L]

    The sitewide ridrect works well but if someone did type https://www.mysite.com/pagetwo/ it wouldn’t redirect to the https version basically i need to do a redirect for each page

    Ahh.. try moving the WordPress stuff to the bottom.

    RewriteOptions inherit
    <IfModule LiteSpeed>
    RewriteEngine on
    </IfModule>
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^mywebsite.co.uk [NC]
    RewriteRule ^(.*)$ https://www.myswebsiye.co.uk/$1 [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^mywebsite\.co\.uk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mywebsite\.co\.uk$
    RewriteRule ^index\.html$ "https\:\/\/www\.mywebsite\.co\.uk\/" [R=301,L]
    
    # BEGIN WordPress
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Thread Starter timmer81

    (@timmer81)

    This seems to have solved the issue, big thanks to you! But the only other issue is if I type
    www.mywebsite.co.uk it forwards to this https://.www.myswebsite.co.uk/ error page reads
    This site can’t be reached

    .www.mywebsite.co.uk’s server DNS address could not be found.
    DNS_PROBE_FINISHED_NXDOMAIN

    Try and change this line:

    RewriteRule ^index\.html$ "https\:\/\/www\.mywebsite\.co\.uk\/" [R=301,L]

    To:

    RewriteRule ^index\.html$ https://www\.mywebsite\.co\.uk/ [R=301,L]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘301 redirect from http to https page level’ is closed to new replies.