[英]HTAccess ReWrite Rules Conflicting?
I have two re-write rules one as a vanity url so for example domain.com/url and one to edit some a data aka post. 我有两个重写规则,一个是虚荣网址,例如domain.com/url,另一个是编辑一些数据帖子。
For some reason only the first rule is taking place and not both 由于某些原因,只有第一条规则在发生,而并非同时发生
Why is that and how can I fix it?? 为什么会这样,我该如何解决?
Here's The Code 这是代码
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]
RewriteCond
is only applicable to very next RewriteRule
not to all the RewriteRule
. RewriteCond
仅适用于下一个RewriteRule
而不适用于所有RewriteRule
。 Also change order of your rules. 还要更改规则的顺序。
Change your code to this: 将代码更改为此:
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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.