【问题标题】:HTAccess ReWrite Rules Conflicting?HTAccess 重写规则冲突?
【发布时间】:2014-10-20 09:43:38
【问题描述】:

我有两个重写规则,一个是虚 url,例如 domain.com/url,另一个是编辑一些数据,也就是帖子。

由于某种原因,只有第一条规则正在发生,而不是两者都发生

为什么会这样,我该如何解决??

这是代码

RewriteEngine On

# Make sure you only match on files/directories that don't actually exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
# Rewrite the first part after the `/` into a `username` parameter

RewriteRule ^(.+)$ groups/index.php?gname=$1 [L,QSA]


RewriteRule ^edit/id/([0-9]+)/?$ groups/view_update.php?pid=$1 [NC,QSA,L]

【问题讨论】:

    标签: php .htaccess url mod-rewrite redirect


    【解决方案1】:

    RewriteCond 仅适用于下一个RewriteRule,而不适用于所有RewriteRule。同时更改规则的顺序。

    将您的代码更改为:

    RewriteEngine On
    # Make sure you only match on files/directories that don't actually exist
    RewriteBase /
    # Rewrite the first part after the `/` into a `username` parameter
    
    # skip all rewrite rules for file or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    
    RewriteRule ^edit/id/([0-9]+)/?$ groups/view_update.php?pid=$1 [NC,QSA,L]
    
    RewriteRule ^(.+)$ groups/index.php?gname=$1 [L,QSA]
    

    【讨论】:

    • 试过同样的问题 :( 非常烦人,谢谢到目前为止 编辑:没关系让它工作 :D 只需改变周围的 re-wrtie 规则 :D
    猜你喜欢
    • 2012-06-09
    • 2021-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多