Forum Moderators: phranque
I seem to be either creating a loop or something. Here is what I have.
The objective is to capture anyone wanting to go outside the SSL prtected zone (http) to (https) and anyone attempting to go to the non-www domain. So I researched and found several different ways to do this and I came up with this. The first rewrite works flawless as does the 3rd one. The middle one doesn't work.
So basically, if you type [mysite.com...] or [mysite.com,...] I want to send you to [mysite.com....] And I would like to catch any other variations that come after mysite.com like mysite.com/store or mysite.com/contact etc.
I was really hoping that the middle set of rewrite code would work. It looks like it would cover everything.
Here are my server details:
Server OS: Linux 2.6.22.10
Database: MySQL 5.0.75
HTTP Server: Apache/2.2.8 (Unix) FrontPage/5.0.2.2635
PHP Version: 5.2.6 (Zend: 2.2.0)
The code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ [mysite.com...] [L,R=301]
# RewriteEngine On
# RewriteCond %{HTTPS} !=on
# RewriteRule .* [%{HTTP_HOST}%{REQUEST_URI}...] [R,L]
# RewriteEngine On
# RewriteCond %{HTTPS} !=on
# RewriteCond %{HTTP_HOST} !^www\.
# RewriteRule ^(.*)$ [%{HTTP_HOST}...] [R=301,L]
Nevertheless, you can change the condition back to
RewriteCond %{HTTPS} !=on
Ditch IE and use Firefox with the "Live HTTP Headers" add-on... Big productivity gain, and better "Alpha testing" value as well: That add-on lets you view all the headers passing back-and-forth between your server and your browser, and makes many redirection, protocol, port-selection, cache-control, authentication, and MIME-type problems a *lot* easier to spot. It's basic kit.
Jim
When I used the RewriteCond %{HTTPS} !=on query, the loop would start as well as when the port 443. It must have conflicted with the PHP.