你可以建立一个非常简单的
/path/to/example.org/web-root/about.html
要使用达到mod这是做什么的...
以下内容作为夏延/ 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
]
]
然后在您httpd.cfg添加模块,像这样:
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
]
重启夏安瞧!
如果你看看其他mods的源码,你可以很容易地设置一个关键字在httpd.cfg文件中使用,以便在mod中设置auto-ext变量。
不完全是你想要的,但你可以通过使用on-status-code [404 rewrite.rsp]配置参数来实现。并且在rewrite.rsp里面,如果文件存在,只是将请求转发到* .html,否则显示你的404页面。 – endo64 2014-10-29 09:52:22
@ endo64是的,这有点破解。 Cheyenne应该(不是说Apache更好)有一种将规范URL映射到静态资源的方式,理想情况下与'Accept'头部绑定... – rgchris 2014-10-29 16:41:48