【问题标题】:What is the difference between RewriteRule ^ index.php and RewriteRule . index.php and [duplicate]RewriteRule ^ index.php 和 RewriteRule 有什么区别。 index.php 和 [重复]
【发布时间】:2015-10-27 01:48:28
【问题描述】:
RewriteRule ^ index.php

RewriteRule . index.php

RewriteRule ^/?$ index.php

RewriteRule ^.*$ index.php

?

这些规则的操作有什么不同吗?

【问题讨论】:

    标签: apache .htaccess mod-rewrite url-rewriting rewrite


    【解决方案1】:
    RewriteRule ^ index.php
    

    匹配任何网址

    RewriteRule . index.php
    

    匹配任何至少一个字符长的网址(实际上,因为这包括/,所以匹配所有网址)。

    RewriteRule ^/?$ index.php
    

    仅匹配 / 和空字符串。 ^ 匹配 URL 的开头,/? 匹配可选的 /$ 匹配 URL 的结尾。因此,唯一可能的匹配是一个不包含字符的 URL 和一个完全由 / 组成的 URL。

    RewriteRule ^.*$ index.php
    

    匹配任何 URL。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-07
      • 1970-01-01
      • 2014-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-27
      相关资源
      最近更新 更多