Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I'm trying to accomplish is:

1. A person, with IP loads my webserver ( and reaches htdocs/
2. Another person, with ip does the same request, and reaches htdocs/folder/

If possible, I'd like to stick to port 80 requests only.

I'm currently using the setup:

<LocationMatch "/">
    Order deny,allow
    Deny from all
    Allow from ::1 localhost
    ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var

    ServerAdmin frederik@*.dk
    DocumentRoot "/XAMPP/htdocs/"
    ErrorLog "logs/lan-error.log"
    CustomLog "logs/lan-access.log" combined

I'd like to allow everyone else to see the folder. And then, depending on the client IP, set another DocumentRoot.

share|improve this question
up vote 1 down vote accepted

I don't think you can do it the way you're envisioning (with conditional DocumentRoot). However, you can achieve the same thing with Apache Rewrites by adding the following to your VirutalHost declaration, or in the .htaccess file in your document root:

RewriteEngine On 
RewriteCond %{REMOTE_HOST} !^192\.168\.1\.5
RewriteCond %{REQUEST_URI} !^/blog/?
RewriteCond %{REQUEST_URI} /(.*)$
RewriteRule (.*) /blog [R=301,L]

Essentially, if the user's IP isn't your IP address, and they're not requesting something in the /blog folder, it will redirect them to the /blog folder. If it's your IP address, or if they're requesting something in the /blog folder, then no redirect will occur.

share|improve this answer
I believe I'll stick to listening to another port. But upvoted and accepted, for a legit answer. – Frederik Spang Feb 27 '13 at 7:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.