.htaccess重写规则解释(简单)


  RewriteCond %{SERVER_PORT} !^443$
  RewriteRule MATCHME https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

如果MATCHME不在URL中,那么重写规则将不被处理吗?你能给我一些文件吗?

正确。如果模式MATCHME不存在,则不进行重写。

如果您需要在RewriteCond处于活动状态时匹配一个捕获所有规则,您可以指定一个额外的规则,如:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule MATCHME https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# Catch-all rule
RewriteRule ^(.*)$ https://%{SERVER_NAME}/someotherpage [L,R,QSA]

查看mod_rewrite文档

最新更新