apache Apache重写URL但不重写某些文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2264107/
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
Apache rewrite URL but don't rewrite certain folder
提问by Nic Hubbard
I am using Apache to rewrite my URLs into clean URLs.
我正在使用 Apache 将我的 URL 重写为干净的 URL。
RewriteRule ^(.*) index.php
Currently this rewrites directories too, which is what I want, since I want everything run through my router/index.php file.
目前这也重写了目录,这正是我想要的,因为我希望所有内容都通过我的 router/index.php 文件运行。
What I would like to do however, is have one folder that I can access directly. This is for lib files such as .js and .css files. I know how to do this with an Alias, but I can't use that in a .htaccess file, which I need to use.
然而,我想做的是有一个我可以直接访问的文件夹。这是用于 lib 文件,例如 .js 和 .css 文件。我知道如何使用别名来执行此操作,但我无法在需要使用的 .htaccess 文件中使用它。
How can I not rewrite a specific folder, eg. called "lib"?
我怎么能不重写特定的文件夹,例如。叫做“lib”?
EDIT:
编辑:
I did find the following example of how to fake an Alias in .htaccess, but I can't get it working:
我确实找到了以下有关如何在 .htaccess 中伪造别名的示例,但我无法使其正常工作:
RewriteRule /old-folder /new-folder [PT]
回答by Ignacio Vazquez-Abrams
RewriteRule ^/?lib/.+$ - [L]
RewriteRule ^(.*) index.php

