Jump to content

Recommended Posts

I have a PHP pages on my site that I need to be forced to always use SSL and non-www. My site is currently in a subfolder while in development (domain.com.au/site/) and I will be moving it to the root domain in the next few days (domain.com.au)

 

The following code works fine other than redirecting www to non-www when SSL is already called. ie https://www.domain.com.au/site/subscribe.php does not redirect to https://domain.com.au/site/subscribe.php

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.domain.com.au [NC]
RewriteRule ^(.*)$ http://domain.com.au/site/$1 [L,R=301]

RewriteCond %{HTTPS_HOST} ^www.domain.com.au [NC]
RewriteRule ^(.*)$ http://enduromag.com.au/site/$1 [L,R=301]

RewriteCond %{REQUEST_URI} ^/site/subscribe.php [OR]
RewriteCond %{REQUEST_URI} ^/site/administrator.php [OR]
RewriteCond %{REQUEST_URI} ^/site/manage-subscription.php
RewriteRule .* - [E=needhttps:on]

RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:needhttps} =on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.