rgc*_*ris 3 rebol url-rewriting cheyenne
我正在使用Cheyenne v0.9并希望提供静态HTML文件text/html,但我不希望URL包含.html扩展名.有没有办法在不使用CGI或其他动态处理器的情况下执行此操作?
例如:
/path/to/example.org/web-root/about.html
Run Code Online (Sandbox Code Playgroud)
使用以下方式联系:
http://example.org/about
Run Code Online (Sandbox Code Playgroud)
Apache等效的'ReWrite'类似于:
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
Run Code Online (Sandbox Code Playgroud)
你可以建立一个非常简单的mod来做到这一点......
将以下内容保存为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
]
]
Run Code Online (Sandbox Code Playgroud)
然后在你的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
]
Run Code Online (Sandbox Code Playgroud)
重新开始夏安和瞧!
如果您查看其他mod的源代码,您可以非常轻松地设置一个关键字,以便在httpd.cfg文件中使用,以便在mod中设置auto-ext变量.
| 归档时间: |
|
| 查看次数: |
90 次 |
| 最近记录: |