Solved

.htaccess Redirect Probem

Posted on 2013-11-10
4
399 Views
Last Modified: 2013-11-12
I am upgrading my site and want to redirect all users to goto a specific landing page when they goto my site now. I want my IP to be the only one not to be recirected.

Will redirect the user to domain01.com/upgrading-site.html

Is there a way I can make it to redirect to update.domain01.com/index.htm

RewriteEngine On
RewriteBase /
#this is your the IP that you connect from
RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1
#this is the temporary landing page
RewriteCond %{REQUEST_URI} !/upgrading-site\.html$
RewriteRule .* /upgrading-site.html [R=302,L]
0
Comment
Question by:Computer Guy
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39637285
RewriteEngine on

#urls to exclude - exclude landing page and css/image folder that are accessed by landing page to avoid loops
RewriteCond %{REQUEST_URI} !/url-to-exclude-1$
RewriteCond %{REQUEST_URI} !/url-to-exclude-2$
RewriteCond %{REQUEST_URI} !^/images$
RewriteCond %{REQUEST_URI} !^/css$
RewriteCond %{REQUEST_URI} !^/$

#ip to allow access
RewriteCond %{REMOTE_HOST} !^11\.11\.11\.11$

#redirect url
RewriteRule .? /http://www.mydomain.com [R=302,L]
0
 
LVL 3

Author Comment

by:Computer Guy
ID: 39637291
Can you please fill in RewriteCond %{REQUEST_URI} !/url-to-exclude-1$
RewriteCond %{REQUEST_URI} !/url-to-exclude-2$ with examples?
0
 
LVL 3

Author Comment

by:Computer Guy
ID: 39637325
Well, let me ask this, with I found something, but can I make the 4th line with the extensions only work in the /upgrade directory? so add upgrade before the extensions so they pick up. if someone goes to contact.php in the root, it the htaccess won't redirect them since PHP is included in the rewrite, so if I have the rewrite rule to only use php file in upgrade dir

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/upgrade.html$
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js|php|txt) [NC] ####ONLY THE UPGRADE FOLDER
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
RewriteRule $ "http\:\/\/www\.domains\.com\/upgrade/upgrade.html" [R=302,L]
0
 
LVL 9

Accepted Solution

by:
QuinnDex earned 500 total points
ID: 39637342
name your contact page in your exemptions

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/upgrade.html$
RewriteCond %{REQUEST_URI} !/contact.php
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js|php|txt) [NC] ####ONLY THE UPGRADE FOLDER
RewriteCond %{REMOTE_HOST} !^888\.888\.888\.888
RewriteRule $ "http\:\/\/www\.domains\.com\/upgrade/upgrade.html" [R=302,L]
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Read about why website design really matters in today's demanding market.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

708 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

15 Experts available now in Live!

Get 1:1 Help Now