Forum Moderators: phranque
After searching on Google and this forum I found the following post:
[webmasterworld.com...]
mikemwe uses the following code:
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ [mysite.com...] [R,L]
To rewrite all https:// url's to http://
Is this method full proof? I have no use for making certain folders secure or anything like that. I just don't want any https:// url's.
And how about using R=301 instead of R?
Google has already indexed some https links even though I don't use any https links on my site.
Ignore LB keepalive HEAD/GET requests on incoming (optional).
You'll get better performance if you match on the first character "." and pass the REQUEST_URI instead of eval'ing the entire URL .*, buffer ( ) and substitute as $1. You are grabbing and processing every request (.*) anyway so just stop processing on the first character match and apply condition and rule.
RewriteCond %{REQUEST_URI} !/keepalive\.html
RewriteRule . [%{HTTP_HOST}%{REQUEST_URI}...] [L]
David
Add exclusions to the code to disable it unless the request comes from your own IP address. Then, as long as there are no "fatal" syntax errors in the code, you can test on your live server with no impact to regular visitors. Just precede each rule with
RewriteCond %{REMOTE_ADDR} =192.168.0.2
replacing that IP address with your real IP address. This prevents the code from running unless the request comes from *exactly* your own IP address. If you're on a dynamic IP address, then you can probably make it work better by omitting the last octet of the IP address, as in
RewriteCond %{REMOTE_ADDR} ^192\.168\.0\.
This will make the code more forgiving if the last octet of your IP address changes frequently, but it will also allow the code to run if anyone requests your site from the same ISP subnet that you are assigned to (which is not terribly likely, but possible).
If you cannot test on your live server -- say by defining and testing in a 'test' subdomain, then you need to set up a test server. While this may take several days (or even more, the first time), it will save you a lot of time and headaches in the future. Or you could rent a separate server just for testing from the same host -- or at least one that is set up identically to your 'real' server.
The code above appears to be sound -- if a bit redundant; only the second RewriteCond should be needed. But if you can't/won't test it, then anything you read here is just an opinion, and you're at an impasse.
I would recommend that you either invest the time in learning enough about Apache so that you can read and understand this kind of code with confidence, or do not use such code at all. This is server configuration code, and it is dangerous to put such code on your server if you you don't understand it and cannot modify it and/or maintain it. Not only must it be syntactically correct, but it must do exactly what you want it to do; Understanding what it does with URL requests and what the 'side effects' of its actions will be with regard to both visitors and search ranking are both critically important.
The preceding statement is not meant to be harsh, but rather a simple statement of reality. It is offered with your best interests in mind. Our Forum Charter contains links to some resources to help you get started.
Jim