Rewriting URLs to remove .html extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx%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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux