httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Boyle <>
Subject Re: mod_rewrite IP -> URL: Read this first...
Date Tue, 18 Dec 2001 09:31:26 GMT
Kyle wrote:
> I'm pulling my hair out here, and I don't have much left.  Can anyone
> send me an example of how to change an IP to a URL on the user's
> browser?  In other words, user types in this:
> http://XXX.XXX.XXX.XXX/whatver
> and mod_rewrite does it's magic and the user's browser displays this in
> the address bar:
> Can mod_rewrite do this?  If so, I've been RTFMing all afternoon and I
> just don't see how to do it.  Any guidance would be greatly appreciated.
> I wish someone would write a new doc called, "mod_rewrite for
> dumbasses".  MAYBE then I'd get it.

Hang on a minute. The other response I sent concentrates on solving your
problem without any regard to the technique used. In it, I recommend
that you *don't* use mod_rewrite but that you use Redirect instead. My
thinking was that your problem is so simple that mod_rewrite is a bit of
an overkill when a simple Redirect can do the job in one line with no
extra modules.

Having written that, it occurs to me that you might *want* to use
mod_rewrite and might think my post implies that mod_rewrite cannot be
used for the purpose of redirection. This is not exactly true and, in
fact, mod_rewrite can be used for practically anything. So if you want
to use mod_rewrite, go right ahead!

This time, the secret lies in the use of the "R" flag to the rewrite
rule - this flag forces the server to generate a "302 - moved
permanently" message which causes the browser to re-issue the request
and thus change its location window contents. e.g.

<VirtualHost XXX.XXX.XXX.XXX>
RewriteRule  ^/(.*)$1 [R]

Sorry for the confusion!

Owen Boyle.

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message