How do you suppress .html from URLs of static HTML files using Cheyenne?
I am using Cheyenne v0.9 and would like to serve static HTML files as text/html
, but I do not want URLs containing the .html
. Is there a way to do this without using CGI or some other dynamic processor?
For example:
/path/to/example.org/web-root/about.html
Use is achieved:
http://example.org/about
Apache's 'ReWrite' attribute would look something like this:
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
+3
source to share
1 answer
you can create a very simple mod that does this ...
save the following as cheyenne / mods / mod-auto-ext.r
REBOL []
install-HTTPd-extension [
name: 'mod-auto-ext
order: [url-translate first]
auto-ext: '.html ; use whatever automatic extension you want!
url-translate: func [req /local cfg domain ext][
unless req/in/ext [
req/in/ext: auto-ext
append req/in/target req/in/ext
]
; allow other mods to play with url (changing target path for example)
return none
]
]
then add your module to your httpd.cfg like this:
modules [
auto-ext ;<----- put it as first item in list, whatever mods you are using.
userdir
internal
extapp
static
upload
expire
action
;fastcgi
rsp
ssi
alias
socket
]
restart cheyenne and voila!
If you look at the source for other mods, you can very easily customize the keyword to use in the httpd.cfg file to set up the auto-ext variable inside the mod.
+5
source to share