Solved

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

Posted on 2012-03-26
1
312 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to dynamically set the form action using jQuery.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

809 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