[英]How do you suppress .html from the URLs of static HTML files with Cheyenne?
I'm using Cheyenne v0.9 and would like to serve static HTML files as text/html
, but I don't want the URLs to contain the .html
extension. 我正在使用Cheyenne v0.9并希望将静态HTML文件作为
text/html
,但我不希望URL包含.html
扩展名。 Is there a way to do this without using CGI or some other dynamic processor? 有没有办法在不使用CGI或其他动态处理器的情况下执行此操作?
For example: 例如:
/path/to/example.org/web-root/about.html
To be reached using: 使用以下方式联系:
http://example.org/about
The Apache equivalent 'ReWrite' would be something like: Apache等效的'ReWrite'类似于:
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
you can build a very simple mod which does this... 你可以建立一个非常简单的mod来做到这一点......
save the following as cheyenne/mods/mod-auto-ext.r 将以下内容保存为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 within your httpd.cfg like so : 然后在你的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
]
restart cheyenne and voila! 重新开始夏安和瞧!
If you look at the source for other mods, you can VERY easily setup a keyword for use in the httpd.cfg file in order to setup the auto-ext variable within the mod. 如果您查看其他mod的源代码,您可以非常轻松地设置一个关键字,以便在httpd.cfg文件中使用,以便在mod中设置auto-ext变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.