Solved

How to redirect all traffic from http to https, but allow traffic from our companys IP range to access the standard http protocol?

Posted on 2007-11-15
4
696 Views
Last Modified: 2013-12-25
I have several websites for our company that I have setup with SSL, however I curently have it configured to ALWAYS redirect a http request to a https request. I would like to keep this system intact however I would like to NOT REDIRECT traffic coming from inside our office (hence from our companys IP range). Is this possible with the apache config files or htaccess? I'm a bit confused on how to configure the htacccess code. Thank you!
0
Comment
Question by:nichiaiinc
  • 2
  • 2
4 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 20289270
You probably can keep You code with following changes. With htaccess

     RewriteEngine On
     RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.
     RewriteCond %{REMOTE_ADDR} !^192\.168\.2\.
     RewriteCond %{SERVER_PORT} !^443$
     RewriteRule (.*) https://%{SERVER_NAME}/$1 [L,R]
0
 

Author Comment

by:nichiaiinc
ID: 20295508
This seems to not work. But actually I dont think any .htaccess file is even being read. I searched google for how to simply redirect all traffic. I put this in the .htaccess file and it didnt do anything.

This is the sample code i used. And nothing happened, the page loaded just as it normally would.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.old-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]

Is something on my server not activated to check out these .htaccess files or something. what am I doing wrong. I created a .htaccess file by  typing

emacs .htaccess while I was in the root directory of my websites folder ie. /var/www/mysite/
0
 
LVL 43

Accepted Solution

by:
ravenpl earned 500 total points
ID: 20296669
You mean You accesing the page as www.old-domain.com and it's not redirected to www.new-domain.com ?
htaccess is ignored only if main httpd.conf says that under given directory You are allowed to override nothing. Refer Your main httpd.conf file.
Also, it's possible that there is no mod_rewrite installed, or You You not allowed to use it.
Also, mod_rewrite needs to operate following Option, try adding it to htaccess as well.
Options +FollowSymLinks
0
 

Author Comment

by:nichiaiinc
ID: 20296800
Raven gets the points. Unfortunately I had already learned all of this from trail and error and using google. But he was dead on in his answer. It was 2 of the three. The module I had not installed yet, that was nice. Then after getting that installed. The apache config files for each website had AllowOverride set to NONE. So i had to change to ALL for the given directories, Then it worked like a charm. Thank nyou very much Raven, and especialy since you gave me the original code, so you get all the points.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question