Apache2 mod_rewrite / mod_proxy problem

Posted on 2005-04-05
Medium Priority
Last Modified: 2012-06-27

I want to serve a website wich is on a server in our DMZ (
There is one (apache) server connected to the internet (accessable by a few dns entries)

The main reason to block all exept IE is that the site contains material that should be only accessable by my colleages and they shouldn't be able to download the contents with ease.

I have this vitrualhost and it works great,

<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass /
ProxyPassReverse /
ServerName tst.no-ip.org
ErrorLog /var/log/apache2/error.log-nuggets
LogLevel notice
CustomLog /var/log/apache2/access.log-nuggets combined
ServerSignature On

Considdering this site only supports IE, i want to redirect all other User Agents to an error page. Thus in comes mod_rewrite.
I've came up with this:

<VirtualHost *:*>
DocumentRoot /var/www/nuggets-test.iconnect.no-ip.org/
RewriteEngine On
RewriteLogLevel 9
RewriteLog "/var/log/apache2/tst-rewrite_log"
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$
RewriteRule / "" [P,L]
RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*$
RewriteRule / "http://tst.no-ip.org/error.html" [L]
ServerName test.no-ip.org
ErrorLog /var/log/apache2/error.log-nuggets
LogLevel notice
CustomLog /var/log/apache2/access.log-nuggets combined
ServerSignature On

However, this does not work, i see no pictures/wrong style sheet. the rewriting seems to work ok.

I'm stuck, can anyone help me?
Question by:Noordeloos
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 16

Expert Comment

ID: 13706065
You need possibly just one rewrite rule, that of the error

RewriteRule ^.*$ "http://tst.no-ip.org/error.html" [R]
LVL 51

Expert Comment

ID: 13714410
you redirect *any* request from non-IE to the same URL, hence a picture is also redirected to that URL
not shure if this works:

RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*$
RewriteRule / "http://tst.no-ip.org/error.html" [R,L]

oops, Manav still said this ;-)

Accepted Solution

AlexeyZilber earned 1500 total points
ID: 13729523
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$
RewriteRule / "" [P,L]

RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$
RewriteRule ^[/]?(.*)$1 [P,L]

Author Comment

ID: 13734653
The P did the trick!
This is it now:

<VirtualHost *:*>
<Proxy *>
 Order Allow,Deny
 Allow from All
 Deny from
 Deny from

ServerSignature On
ServerName test.iconnect.no-ip.org
RewriteEngine On
RewriteLogLevel 1
RewriteLog "/var/log/apache2/iconnect.no-ip.org/rewrite.log"
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$      [OR]
RewriteCond %{HTTP_USER_AGENT} ^NSPlayer.*$      [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Windows-Media-Player.*$
RewriteRule ^/(.*)$1 [P,L]
RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*$      [OR]
RewriteCond %{HTTP_USER_AGENT} !^.*Windows.*$      [OR]
RewriteRule / "http://iconnect.bounceme.net/error.html" [L]

LogLevel info
ErrorLog /var/log/apache2/iconnect.no-ip.org/error.log
CustomLog /var/log/apache2/iconnect.no-ip.org/access.log combined

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 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