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
695 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

#SSL #TLS #Citrix #HTTPS #PKI #Compliance #Certificate #Encryption #StoreFront #Web Interface #Citrix XenApp
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now