.htaccess question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fenris Wolf
    Confirmed User
    • Nov 2005
    • 1059

    #1

    .htaccess question

    I am hoping someone can help with this issue. I need to force www and https on my site and I am using the following code in my .htaccess file:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !=""
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    Everything works fine when typing the domain directly but when linking deep within the site it only redirects to www and not https as well. So typing h ttp://domain redirects to h ttps://www.domain.com but when typing h ttp://domain.com/anything redirects to h ttp://www.domain.com/anything.
    Email: fenris_wolf3000 (a t ) yah00 . c 0 m
  • Bladewire
    StraightBro
    • Aug 2003
    • 56228

    #2
    See if this works

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]


    Skype: CallTomNow

    Comment

    • Fenris Wolf
      Confirmed User
      • Nov 2005
      • 1059

      #3
      Originally posted by Bladewire
      See if this works

      RewriteCond %{HTTPS} off
      RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
      RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

      RewriteCond %{HTTPS} on
      RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
      RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

      RewriteCond %{SERVER_PORT} !^443$
      RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
      That did the trick. Thank you so much.
      Email: fenris_wolf3000 (a t ) yah00 . c 0 m

      Comment

      Working...