[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
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
?
702 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Tech spooks aren't just for those who are tech savvy, it also happens to those of us running a business. Check out the top tech spooks for business owners.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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…

650 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