apache mod_rewrite 还是 mod_alias?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/808014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mod_rewrite or mod_alias?
提问by jeph perro
I have a server, its httpd.conf already has some "RedirectMatch permanent" directives in it.
我有一个服务器,它的 httpd.conf 中已经有一些“ RedirectMatch Permanent”指令。
I'm not that familiar with mod_alias, I've only ever used mod_rewrite.
我对 mod_alias 不太熟悉,我只使用过 mod_rewrite。
What's the basic difference? I don't see a "L" flag in mod_alias to stop processing rules.
基本的区别是什么?我在 mod_alias 中没有看到“L”标志来停止处理规则。
Which one should I use for best practices of redirecting from one sub-domain to another?
对于从一个子域重定向到另一个子域的最佳实践,我应该使用哪一个?
Can I use both at the same time and will it be obvious which takes precedence?
我可以同时使用两者吗,哪个优先?
采纳答案by Chad Birch
mod_alias is basically a simpler version of mod_rewrite. It can't do some things that mod_rewrite can, such as manipulate the query string. If you're able to choose either of them, I don't see any reason that you'd want to use mod_alias.
mod_alias 基本上是一个更简单的 mod_rewrite 版本。它不能做一些 mod_rewrite 可以做的事情,比如操作查询字符串。如果您能够选择其中任何一个,我看不出您有任何理由想要使用 mod_alias。
Is there a specific reason you need to try to use both together?
是否有特定的原因需要尝试同时使用两者?
Apache mod_rewrite & mod_alias tricks you should knowseems to be a good article about the two. It notes at one point that mod_rewrite rules get executed before mod_alias ones.
你应该知道的 Apache mod_rewrite & mod_alias 技巧似乎是一篇关于这两者的好文章。它在某一时刻注意到 mod_rewrite 规则在 mod_alias 规则之前执行。
回答by Michael K?fer
As the accepted answer says: mod_rewritecan do things which mod_aliascan't. However the main benefit of mod_aliasis that it is easier to use.
正如公认的答案所说:mod_rewrite可以做不能做的事情mod_alias。然而,主要的好处mod_alias是它更容易使用。
The apache docs say that we should use mod_aliasfor simple things like redirects and mod_rewriteonly for things we cannot do with simpler modules like mod_alias. View the docs: When not to use mod_rewrite.
apache 文档说我们应该mod_alias用于简单的事情,比如重定向,并且mod_rewrite只用于我们不能用更简单的模块做的事情,比如mod_alias. 查看文档:何时不使用 mod_rewrite。

