httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fran├žois Beausoleil <franc...@teksol.info>
Subject [users@httpd] Rewriting URLs to remove .html extension
Date Wed, 15 Oct 2008 16:29:39 GMT
Hi all!

I moved my blog from a CMS to plain files.  My old links are of the  
form:

http://blog.teksol.info/tags/unit-testing

All files are now stored with a .html extension, such that

%{DOCUMENT_ROOT}/tags/unit-testing.html

is an existing file.

I found a thread in 2004 which talked about this problem:

http://mail-archives.apache.org/mod_mbox/httpd-users/200410.mbox/%3C416E8250.2040504@zetnet.co.uk%3E

The URL Rewriting Guide's Canonical URLs example is also similar to  
this.

I can't seem to make things work.  Here's my .htaccess:
# ------------------
RewriteEngine on

# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA,L]

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [QSA,L]

# Rewrite X.html to X only
#RewriteRule ^(.*)\.html$ $1 [R=301,L]
# ------------------

I'm reading my first rule as "Rewrite / to /index.html" and end there.

My second rule is supposed to read "If there exists a file named  
X.html, rewrite to that and end", but it doesn't work.  When I ask  
for /tags/unit-testing, I get a 404.

The third rule (which is commented out) is supposed to rewrite X.html  
to X.  But when I have that enabled, requests without a .html  
extension end up in an infinite redirection loop for the 404 page.

This is hosted on DreamHost and I can't active the rewrite log.  If I  
had the log, I would probably be able to fix my problem myself!

I'm pretty sure my error is simple.  If anybody had a quick pointer,  
I'd really appreciate.

Thanks!
--
Fran├žois Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/


---------------------------------------------------------------------
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
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message