代码之家  ›  专栏  ›  技术社区  ›  John McCollum

将规则改写为Zeus服务器规则(Codeigniter)

  •  3
  • John McCollum  · 技术社区  · 16 年前

    我即将上线一个由Codeigniter驱动的网站。我想从url中删除index.php,而不是这样:

    http://www.mysite.com/index.php/controller
    

    我得到这样的东西:

    http://www.mysite.com/controller
    

    到目前为止,相当简单。过去,我使用了Codeigniter文档提供的mod重写规则:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    这就像一个魅力。然而,对于这个网站,我必须使用Zeus web服务器而不是Apache,而且我对它一点也不熟悉。Zeus有自己的重写规则,如下:

    RewriteCond %{REQUEST_FILENAME} !-f  
    RewriteRule ^[^/]*\.html$ index.php
    

    会变成这样:

    match URL into $ with ^/[^/]*\.html$
    if matched then set URL = /index.php
    

    有人能帮我改写宙斯的第一条规则吗?非常感谢任何帮助!

    1 回复  |  直到 16 年前
        1
  •  3
  •   John McCollum    16 年前

    我想出来了——以下方法对我来说很有效:

    map path into SCRATCH:DOCROOT from /
    
    set SCRATCH:ORIG_URL = %{URL}
    set SCRATCH:REQUEST_URI = %{URL}
    
    look for file at %{SCRATCH:DOCROOT}%{SCRATCH:REQUEST_URI}
    if not exists then look for dir at %{SCRATCH:REQUEST_URI}%{SCRATCH:REQUEST_URI}
    if not exists then set URL = /index.php%{SCRATCH:REQUEST_URI}
    
    推荐文章