Solved

.htaccess Redirect Probem

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video teaches users how to migrate an existing Wordpress website to a new domain.

632 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