Apache rewrite

Posted on 2011-10-26
Last Modified: 2012-06-27

I'm having problems with an Apache rewrite rule. I have the below rewrite (snippet shown) however I need to add to have all traffic coming from a certain site, eg, sent to My IT person is off on leave and I do not want to ruin his work!

Many thanks in advance.

RewriteEngine On

#RewriteCond %{HTTPS} !on
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# For UI Start
RewriteBase /

### For Index page
RewriteRule ^([a-zA-z0-9-_=+]+)/$ index.php?memberdata=$1 [NC,L]

RewriteRule ^([a-zA-z0-9-_=+]+)$ index.php?memberdata=$1 [NC,L]

RewriteRule ^([a-zA-z0-9-_=+]+)/home$ index.php?memberdata=$1 [NC,L]

RewriteRule ^([a-zA-z0-9-_=+]+)/home/$ index.php?memberdata=$1 [NC,L]
Question by:LetsLearn
    LVL 19

    Expert Comment

    In the VirtualHost directive for put:

    RewriteEngine On
    RewriteRule ^/(.*)$1 [L,R]

    This will work if they just put the base site, or if they put /foo/bar.htm on the end, it will take them to the alternate site with the same path extension.

    Author Comment

    sorry just one more question what if it is a only sub-directory to a sub-directory? eg to
    LVL 19

    Accepted Solution

    Even easier!  The rule below will take them to the page they are requesting in /folder/home on the other end, but if you don't want that, simply remove the $1 on the end, and then requests for /folder/home/* will just go to
    RewriteRule ^/folder/home/(.*)$1 [L,R]

    Open in new window


    Author Closing Comment

    Thanks for your help, much appreciated!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
    If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now