You are not logged in. Login Now
 0-3   4-11         
 
Author Message
remmers
An Exercise in URL Rewriting Mark Unseen   Mar 8 17:49 UTC 2007

The mod_rewrite module of the Apache webserver can be used to translate 
a requested URL to a different one.  This is useful for example if a 
page has been moved to a new location, but you still want the old URL to 
work.

If the webserver has been configured to allow it, this facility is 
available to users on a per-directory basis.  You create a file 
named .htaccess in the directory in which you want URL translations to 
apply and put some directives in the file that specify how the 
translation should be done.

As an exercise for myself in writing .htaccess files, I've implemented a 
simplified URL scheme for read-only access to Grex conferences, items, 
and responses.  It works as follows:

  http://jremmers.org/grex/bbs               -list of all conferences
  http://jremmers.org/grex/bbs/CONF          -index of conference CONF
  http://jremmers.org/grex/bbs/CONF/ITEM     -content of an item
  http://jremmers.org/grex/bbs/CONF/ITEM/SEL -selected part of an item

Examples:

  http://jremmers.org/grex/bbs/kitchen     -index of kitchen cf.
  http://jremmers.org/grex/bbs/web/5       -item 5 of web cf.
  http://jremmers.org/grex/bbs/web/5/2     -resp 2 of item 5 of web cf.
  http://jremmers.org/grex/bbs/web/5/1-4   -resps 1-4 of that item

Note that even though the domain given in the URLs is my website, no 
Grex conference content is actually stored there.

Feel free to play around with this.  I'll explain how I did it in a 
subsequent response.
11 responses total.
other
response 1 of 11: Mark Unseen   Mar 9 13:21 UTC 2007

What does that do to web logs?  Is the rewritten URL logged as referrer?
remmers
response 2 of 11: Mark Unseen   Mar 9 21:08 UTC 2007

Hm, dunno.  Anybody?
remmers
response 3 of 11: Mark Unseen   Mar 9 21:59 UTC 2007

I did some reading up on and experimentation with the HTTP referer 
header.  Typically it's sent by a browser when you follow a link; its 
value is the URL of the page on which the link occurs.  It's a reverse 
link from the target of the original link back to the source.

If you're reading this in Backtalk, you can see the value of the referer 
header by clicking on this link:  http://c2.com/cgi/test/
You'll get a display of the list of HTTP headers that your browser sent 
to the server at c2.com.  Unless your browser is configured not to send 
referer headers, one of the headers will be HTTP_REFERER; its value is 
the URL of the Backtalk page on which the link occurs.

On the other hand, if you go to a URL by simply typing it into your 
browser address window, your browser shouldn't send a referer header.  
You can try this out with c2.com too.

I think all that is completely independent of any rewriting that 
mod_rewrite does, though, since the referer header is sent by the 
browser before any rewriting on the server takes place.

(My starting point for the above was looking at the "HTTP referer" 
article in Wikipedia (http://en.wikipedia.org/wiki/HTTP_Referer).  The 
article points out that the correct spelling is "referrer" and that 
whoever made up the HTTP header name misspelled it.)
 0-3   4-11         
Response Not Possible: You are Not Logged In
 

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss