Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-03-26
1
Medium Priority
?
319 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 51

Accepted Solution

by:
Steve Bink earned 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

885 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