【问题标题】:Help creating URI rewrite using RewriteRule使用 RewriteRule 帮助创建 URI 重写
【发布时间】:2010-11-26 16:34:53
【问题描述】:

我用这个来重写

RewriteRule ^site/(.*) index.php?rewrite=$1 [L]
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase] 

我开始把这个网站变成一个伪mvc系统,真的需要阅读以上内容

1. If the directory is NOT ^site/public/* OR ^site/assets/* or (etc) then re-write the url as index.php?rewrite=$1  (I'm basically trying to replicate the first rule above for all cases except a couple).
2. ALSO, go ahead and rewrite all .xml pages to be changed to .php

【问题讨论】:

    标签: apache url mod-rewrite rewrite


    【解决方案1】:

    您可以设置第一条规则以防止它在这些特定情况下应用:

    # Only apply the rule when the captured section does not start
    # with public/ or assets/
    RewriteCond $1 !^(public|assets)/
    RewriteRule ^site/(.*) index.php?rewrite=$1 [L]
    

    似乎第二条规则已经达到了你的预期,所以如果不是这样,你需要详细说明问题所在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      • 2011-09-28
      • 1970-01-01
      • 2011-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多