Solved

.htaccess Redirect Probem

Posted on 2013-11-10
4
420 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
[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 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
UM7 Stop Sending packets with GPS Sensor 1 44
Exchange OWA website Redirection 7 81
Getting robots.txt Error 9 57
fillable forms on website 2 43
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…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 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