Jump to content

Recommended Posts

Hi, a client of mine purchased and SSL for www.mysite.com (not a wild card SSL)

 

So when a user goes to https://mysite.com, we get some sort non-secure/trusted error.  I'm trying to use mod_rewrite to force the www when it doesn't exist but nothing seems to work.  Here is an example of my rewrite code:

 

RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{SERVER_NAME} ^mysite.com$
RewriteRule (.*) http://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,NC,L]

Link to comment
https://forums.phpfreaks.com/topic/202978-forcing-www-for-https/
Share on other sites

Try this for the rule / cond's:

 

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

 

If that does not work try this for the rule (keep the same conditions as above):

RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,NC,L]

 

Since you are doing the port checking for 443, you should probably make the http be https :)

Well, I never used the SERVER_PORT command before, so I cannot vouch for that at all.

 

But reading some other forums, you may take a look at the ending parts of this forum:

http://www.webmasterworld.com/apache/3970987.htm

 

It talks about your vhosts file and how it needs to be setup properly for this to work right. Let us know if that worked and possibly the right steps you had to take.

Hypothesising about whether the CONDs are being met is irrelevant and pointless, as I asked in my last post does the URL in the address bar change after you have entered your test URL? If it doesn't then either the CONDS or the RULE itself are not being matched.

What your .htaccess file seems to be doing is checking if the request is being made on port 443 and has the domain name mysite.com without any subdomain. So are we saying that the overall objective is to redirect any SSL requests to the base domain to the www. subdomain?

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.