Link to home
Start Free TrialLog in
Avatar of Computer Guy
Computer Guy

asked on

.htaccess Redirect Probem

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]
Avatar of QuinnDex
QuinnDex

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]
Avatar of Computer Guy

ASKER

Can you please fill in RewriteCond %{REQUEST_URI} !/url-to-exclude-1$
RewriteCond %{REQUEST_URI} !/url-to-exclude-2$ with examples?
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]
ASKER CERTIFIED SOLUTION
Avatar of QuinnDex
QuinnDex

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial