是什么在操作之间的差异。和^,而^(。*)$? [英] What is the difference in operation between . and ^ and ^(.*)$?

查看:210
本文介绍了是什么在操作之间的差异。和^,而^(。*)$?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间的操作的区别是什么:

What is the difference in operation between:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

我知道。指任何字符和字符串的^开头。

I know that "." means any character and "^" beginning of string.

感谢您的答复!

推荐答案

首先,让我们了解如何登录页面匹配。

First let's understand how landing page is matched.

有关目标网页的URI模式是 ^ $ 在.htaccess, ^ / $ 在Apache的配置。因此,你可以放心地使用 ^ /?$ 普遍。

For landing page URI pattern is ^$ in .htaccess, ^/$ in Apache config. Thus you can safely use ^/?$ universally.

  1. 您的第一个重写规则将匹配的每个URL(包括登陆页面即 http://domain.com/
  2. 您的第二个重写规则将匹配的每个URL(除登陆页面)。作为一个点不匹配 ^ $ URI模式。
  3. 您的第三个重写规则也将匹配每个URL(包括登陆页面即 http://domain.com 但是有一个不必要的捕获组和仅稍长的版本^
  1. Your first rewrite rule will match every URL (including landing page i.e. http://domain.com/).
  2. Your second rewrite rule will match every URL (except landing page). As single DOT will not match ^$ URI pattern.
  3. Your third rewrite rule will also match every URL (including landing page i.e. http://domain.com) but has an unnecessary capturing group and longish version of just ^.

这篇关于是什么在操作之间的差异。和^,而^(。*)$?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆