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
699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

731 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