什么是重写规则^(。*)/ $?PATH = $ 1 [QSA,L]意味着我的.htaccess? [英] What does RewriteRule ^(.*)/$ ?path=$1 [QSA,L] mean in my .htaccess?

查看:1039
本文介绍了什么是重写规则^(。*)/ $?PATH = $ 1 [QSA,L]意味着我的.htaccess?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在nginx的创建重写的工作是在我的.htaccess也有一些线,我不完全理解。

 的DirectoryIndex index.php文件

RewriteEngine叙述上
的RewriteCond%!-f
重写规则^(。*)/ $?PATH = $ 1 [QSA,L]
 

有人可以解释给我听?

解决方案

的RewriteCond%!-f 似乎不正确规则条件,并总为真。

这条规则:

 重写规则^(。*)/ $?PATH = $ 1 [QSA,L]
 

匹配任何URI与斜线并在内部改写为 /?路径= URI且不斜线

因此​​,对于例如:一个URI /富/ 将被改写为 / PATH = FOO

  • QSA - 查询字符串追加
  • L =最后一条规则

参考: URL重写简介

更新:更改不正确的条件:

 #请求不是一个文件
的RewriteCond%{} REQUEST_FILENAME!-f
#请求不是一个目录
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)/ $?PATH = $ 1 [QSA,L]
 

I need to create rewrite in nginx as is done in my .htaccess and there are some lines which I don't completely understand.

DirectoryIndex index.php

RewriteEngine on
RewriteCond % !-f
RewriteRule ^(.*)/$ ?path=$1  [QSA,L]

Can someone explain it to me?

解决方案

RewriteCond % !-f seems incorrect rule condition and is always evaluating to true.

This rule:

RewriteRule ^(.*)/$ ?path=$1  [QSA,L]

Is matching any URI with trailing slash and internally rewriting to /?path=uri-without-slash

So for ex: an URI /foo/ will be rewritten to /?path=foo

  • QSA - Query String Append
  • L = Last rule

Reference: Apache mod_rewrite Introduction

UPDATE: Change that incorrect condition to:

# request is not for a file
RewriteCond %{REQUEST_FILENAME} !-f
# request is not for a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ ?path=$1 [QSA,L]

这篇关于什么是重写规则^(。*)/ $?PATH = $ 1 [QSA,L]意味着我的.htaccess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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