htaccess语法RewriteRule [英] Htaccess syntax RewriteRule

查看:87
本文介绍了htaccess语法RewriteRule的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试了解我的一些htaccess规则,但无法成功找到合适的文档。

I would like to try to understand some of my htaccess rules but I can't succeed to find the proper documentation.

RewriteRule ^([a-z]{1,2})?\/?style\/(.*).css$ site/scripts/concat-files.php?type=css&page=$2&lang=$1 [L,QSA]

问题1:
我猜这条规则是由这样的事情触发的。 < link rel = stylesheet src =<?php echo URL?> / en / style / accueil.css>
我对 ?

Question 1: I guess this rule is triggered by something like this. <link rel="stylesheet" src =<?php echo URL ?>"/en/style/accueil.css"> Am I right ?

问题2:我知道QSA允许将请求参数从第一个URL保留到重写URL。但是L在做什么?

Question 2: I know QSA allow to keep the request parameter from the first url to the rewrite URL. But what L is doing ?

问题3:规则是由这种事情触发的吗?

Question 3 : Is the rule triggered by this kind of things ?

$urlstyle = URL."en/style/accueil.css";
$style = file_get_contents($urlstyle);

谢谢。

编辑:然后考虑此

$urlstyle = URL_SITE.'en/style/accueil.css';
$style = file_get_contents($urlstyle);
echo $style;

样式已编写。

但是在我的concat-files.php中

But in my concat-files.php

我有这个

$pathfile= PATH . $file;
$sContenu = @file_get_contents( $pathfile);
if( $sContenu !== false) {
    echo $sContenu;
}

这意味着Accueil CSS将被写入2次,否?

It means that accueil css will be written 2 times no ?

但是在我的代码中,我只有一次。

But in my code I have it only once.

推荐答案

编辑

如@nick在评论中所述

1-该规则由任何满足规则本身的http请求触发。或者更确切地说:

Edit
As @nick said in the comments
1 - The rule is triggered by any http request that satisfy the rule itself. or rather :

`1 or 2 alphabetic characters` / style / `any string`.css

2- [L] 表示仅第一条规则适用,其他规则匹配将被忽略。

2 - [L] means thats only first rule will apply, other rules match will be ignored.

3-是的,正如我所说,该规则由满足规则本身的所有http请求触发

3 - Yes, as i said The rule is triggered by any http request that satisfy the rule itself

Edit2

不,看来您没有两次输出相同的内容。

No, it seems that you are not outputting same content two times.

$style = file_get_contents($urlstyle);

您正在将内容分配给 $ style 网址(由一些php代码生成)。
include 函数的行为不同,在这种情况下,这两段代码都将被执行和写入两次。

因此,您只需一次就可以了。

You are assigning to $style the content of an url (generated by some php code). Is a different behaviour from, for example, include function, in that case both pieces of code would be executed and written two times.
So its ok that you have it only once.

这篇关于htaccess语法RewriteRule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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