代码之家  ›  专栏  ›  技术社区  ›  strike_noir

与mod_rewrite等效的UrlRewriteFilter

  •  1
  • strike_noir  · 技术社区  · 16 年前

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule (.*) index.php/$1 [L]   
    

    有人能帮帮我吗?

    3 回复  |  直到 16 年前
        1
  •  0
  •   ChssPly76    16 年前

    这对我奏效了

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
            "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
    <urlrewrite>
        <rule>
            <note>
                Fitler for checking if file exists.
            </note>
            <condition type="request-filename" operator="notfile" next="and" />
            <condition type="request-filename" operator="notdir" />
            <from>(.*)</from>
            <to type="redirect" last="true">index.php/$1</to>
        </rule>
    </urlrewrite>
    
        2
  •  0
  •   yoda    16 年前

    你不能。好吧,如果你使用的是UrlRewriteFilter 3.2版本,你可以编写自己的自定义 class-rule

    这绝对属于Apache的mod_rewrite,特别是考虑到你有 index.php 在你的例子中。为什么该请求甚至会被转发到Tomcat或由其提供服务?

        3
  •  0
  •   Amir Jamak    10 年前

    事实上,你不必担心。Apache的mod_rerwite模块会为您解决这个问题。试试看。。如果您尝试访问服务器中的文件夹或文件,它将打开它,否则它将应用您在其中的重写规则。

    推荐文章