连字符.htaccess文件重写规则 [英] Hyphen in .htaccess file rewrite rule

查看:92
本文介绍了连字符.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.com$ [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文件重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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