Solved

.htaccess Redirect Probem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

896 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