Solved

htaccess redirect to maintenance page but not if they want a page inside of specific folders

Posted on 2012-03-26
1
309 Views
Last Modified: 2012-04-15
Dear Experts,

I am needing to do a few updates on the public portion of my site and need to redirect traffic using htaccess to a maintenance page while I update the pages,  I don't really know where to begin. I am hoping it wont be to complicated but what I need to do is this:

redirect all traffic to a maintenance page called "update.php" unless they need access to a page inside of a folder called "cora" or "member". Also I would like to allow them access to the login and the logout page which is "login.php" and "logout.php"

Also I would still like to allow myself access to the site while I test to make sure the update is working correctly. So I would need to allow my ip address have access to everything.

Many thanks as always
0
Comment
Question by:Lightwalker
1 Comment
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 37774938
Make sure you have mod_rewrite in your Apache installation.  You can see the docs for more information on the directives:

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Something like this should work you:

RewriteCond %{REQUEST_FILENAME} !^/(cora|member)/ [NC]
RewriteCond %{REQUEST_FILENAME} !^/?log(in|out)\.php$ [NC]
# your ip goes on the next line
RewriteCond %{REMOTE_ADDR} !000\.000\.000\.000
RewriteRule ^/?(.*)$ update.php [L]

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Read about why website design really matters in today's demanding market.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

17 Experts available now in Live!

Get 1:1 Help Now