您的请求/messages/process/
与此规则匹配:
RewriteRule ^messages/([a-zA-Z_-]+)/?$ messages.php?page=$1 [L]
...因此您将需要一个更具体的规则,该规则/messages/process/
更早匹配并将其路由到messages-process.php
匹配更通用的规则之前。
将它放在所有其他规则之前将为该特定模式完成它:
RewriteRule ^messages/process/?$ messages-process.php [L]
如果您还有其他process/
需要类似重写的目录,例如/messages/thing
to ,请在其他目录之前messages-thing.php
使用此规则。稍后您将需要明确列出不应被更通用规则匹配的那些...
# Matches /messages/process/ or /messages/otherdirectory/, etc...
RewriteRule ^messages/(process|thing|otherdirectory|somethingelse)/?$ messages-$1.php [L]
总之,这应该可以完成工作:
# Matches /messages/process/ or /messages/otherdirectory/, etc...
RewriteRule ^messages/(process|thing|otherdirectory|somethingelse)/?$ messages-$1.php [L]
RewriteRule ^messages/process/([a-zA-Z_-]+)/([0-9]+)/?$ messages-process.php?do=$1&id=$2 [L]
RewriteRule ^messages/process/ajax/([a-zA-Z_-]+)/?$ messages-process.php?do=$1&ajax=true [L]
RewriteRule ^messages/view/([0-9]+)/?$ messages.php?page=view&id=$1 [L]
# Stuff not matched by the specific rule at the top matches this one...
RewriteRule ^messages/([a-zA-Z_-]+)/?$ messages.php?page=$1 [L]
RewriteRule ^messages/?$ messages.php [L]
更新:
要允许/messages/process/trash
一般重写 URL,您需要在此规则之后添加一条规则:
RewriteRule ^messages/process/([a-zA-Z_-]+)/([0-9]+)/?$ messages-process.php?do=$1&id=$2 [L]
# Match stuff after /process/whatever which are not followed by digits (which the previous rule matches)
RewriteRule ^messages/process/([a-zA-Z_-]+)(?:/[^0-9]+/?)$ messages-proces.php [L]