?
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
Medium Priority
?
701 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 2000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

765 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