Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

See this NYTimes url:

http://opinionator.blogs.nytimes.com/2011/01/02/war-in-the-cabinet/?hp

If we type

opinionator.blogs.nytimes.com/2011/01/02/war-i

in browser, it automatically redirects us to the above article, the only article in that folder starting with "war-i".

How to do this in a site with apache, which serves static html files only? That is, if there is a apache module, without adding scripts, that would be best.

share|improve this question

3 Answers 3

The behavior you're talking about is actually implemented by the script itself, not Apache. That is, note the following site on the official WordPress blog site, which does the same thing (this is just a random blog I found on the front page):

http://bestblog.wordpress.com/2007/06/13/elle-effect/

The same URL can be accessed by going to any combination of the following:

This "pretty URL" is actually enforced by mod_rewrite rules, which rewrites the URL to something that the script can understand, i.e.:

RewriteRule ^([12][0-9]{3})/([0-9]{2})/([0-9]{2})/(.*)$ /somescript.php?year=$1&month=$2&day=$3&title=$4

And so on. The script receives the post title, realizes there's nothing by that name, and searches for titles in the database to see if it can find a match. If it does, it redirects.

I really hope this clarifies what you're looking for!

Andrew

share|improve this answer

The sites that do that do it through their scripting, not the webserver.

If you absolutely have to do it on static HTML, mod_speling can almost do this. Someone dedicated or crazy enough could probably get it to work in a day or so.

share|improve this answer

You can probably get a working implementation together in a few minutes if you're good at writing shell scripts or perl.

mod_rewrite + RewriteMap/MapType: prg + filename completion script

share|improve this answer

Your Answer

 
discard

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.