httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Boyle <...@bourse.ch>
Subject Re: mod_rewrite IP -> URL
Date Tue, 18 Dec 2001 09:03:46 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:
> 
> http://www.mydomain.com/whatever
> 
> 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.

The page Joshua referred you to does indeed contain the solution you are
looking for although it is rather cryptically presented...

Notice that the page (and your posting) concentrate on the use of
mod_rewrite. However, the actual solution lies in the use of "redirect".
These two functions are very similar but the essential difference is
that mod_rewrite is entirely server-side so that any re-writing of the
URL is invisible to the browser and the browser will not change. When
you do a redirect on the other hand, the server replies to the original
request with a 301 or 302 redirect response which causes the browser to
re-issue its request (to the new URL) *and* change its location window
contents. Consider the following example:

Re-write:
---------
<VirtualHost www.banana.com>
RewriteRule  ^/(.*) http://www.kiwi.com/$1

User types in:    http://www.banana.com/cherry.html
Server fetches:   http://www.kiwi.com/cherry.html
Browser displays: http://www.banana.com/cherry.html

Redirect:
---------
<VirtualHost www.banana.com>
RedirectMatch (.*)  http://www.kiwi.com/$1

User types in:      http://www.banana.com/cherry.html
Server sends 301 -> http://www.kiwi.com/cherry.html
Browser requests:   http://www.kiwi.com/cherry.html
User gets served:   http://www.kiwi.com/cherry.html
Browser displays:   http://www.kiwi.com/cherry.html

Read the docs on Redirect and RedirectMatch for the details...

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message