连字符.htaccess文件重写规则

编程入门 行业动态 更新时间:2024-10-28 08:28:32
本文介绍了连字符.htaccess文件重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在看从旧网站我们的老开发商做了这个规则,我也从来没见过。

I am looking at this rule from an old site one of our old developers did, and I have never saw it.

RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?domain$ [NC] RewriteCond %{REQUEST_URI} ^/extension1/(.*)$ [OR] RewriteCond %{REQUEST_URI} ^/extension2/(.*)$ [OR] RewriteCond %{REQUEST_URI} ^/extension3/(.*)$ RewriteRule ^(.*)$ - [L,R=404]

我看到,如果我去域与这些扩展的一个,它只是404的。

I see that if I go to the domain with one of those extensions, it just 404's.

我认为正在发生的事情是,如果它的主机相匹配,与extenions之一,它只是404的。我明白了一切到最后一行,因为 - 抛出我送行。

What I think is happening is if it matches the host, and one of the extenions, it just 404's. I understand everything up to the last line because the - throws me off.

什么的 - 做的最后一条规则

What does the - do in the last rule?

感谢

推荐答案

在 - 表示通过传递URI,什么也不做。它本质上不执行任何到URI和仅适用的标志,在这种情况下,返回404

The - means "pass the URI through and do nothing". It essentially does nothing to the URI and only applies the flags, which in this case returns a 404.

有关更多信息,请参见 mod_rewrite的文档下 - (破折号)

For more info, see the mod_rewrite documentation under "- (dash)"

一个破折号表示没有替代应该执行(现有路径是通过非接触传递)。这用于当一个标志(见下文)需要在不改变路径要施加

A dash indicates that no substitution should be performed (the existing path is passed through untouched). This is used when a flag (see below) needs to be applied without changing the path.

更多推荐

连字符.htaccess文件重写规则

本文发布于:2023-11-01 19:40:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550225.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   字符   规则   文件   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!