需要与Apache重写问题帮助 [英] Need help with Apache Rewrite issues
问题描述
我的开发人员提供了我所需要的我们的应用程序工作的一些阿帕奇重写规则。当我加入他们的Apache我www.domain.com/blog和www.domain.com/phpmyadmin页面不再奏效。我试图加我博客第一的RewriteCond规则,也是最后的phpMyAdmin的规则,但没有一个按预期工作。基本上我想/博客或/ phpMyAdmin的任何请求不能重写,去到我的文档根目录并运行重写之外的应用程序。你能不能帮我找出一个解决方案?谢谢
My developer has provided me some Apache rewrite rules that are required for our application to work. When I added them to Apache my www.domain.com/blog and www.domain.com/phpmyadmin pages no longer worked. I tried to add the first RewriteCond rule for my blog and also the final phpmyadmin rule but neither one is working as expected. Essentially I want any requests to /blog or /phpmyadmin to NOT rewrite and go to my document root directory and run those applications outside of rewrites. Can you help me figure out a solution? Thanks
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^/(.*_css.*\.css.*) /$1 [QSA,L]
RewriteRule ^/(.*_js.*\.js.*) /$1 [QSA,L]
RewriteRule ^/(.*_swf.*\.swf.*) /$1 [QSA,L]
RewriteRule ^/(.*_img.*\.[jpg|JPG|jpeg|JPEG|gif|GIF|bmp|BMP|png|PNG].*) /$1 [QSA,L]
RewriteRule ^/(.*)$ /index.php?url=$1 [QSA,L]
RewriteRule ^/phpmyadmin(.*)$ /phpmyadmin$1 [QSA,L]
</VirtualHost>
它们分别位于www.domain.com/blog和www.domain.com/phpmyadmin。
They are located at www.domain.com/blog and www.domain.com/phpmyadmin.
阿帕奇2.2.13
谢谢!
推荐答案
如果你想避免重复开头的网址 /博客/
或 / phpMyAdmin的/
那么你的可能的能够与第一条规则的存在就完事了:
If you want to avoid rewriting URLs that begin with /blog/
or /phpmyadmin/
then you may be able to get away with the first rule being:
RewriteRule ^/(?:blog|phpmyadmin)/ - [L]
(更换您的的RewriteCond
然后删除旧的phpmyadmin规则)。
(replacing your RewriteCond
and then removing the old phpmyadmin rule).
有一个快速的解释:这个匹配以开头的网址 /博客/
或 / phpMyAdmin的/
并没有按' ŧ重写它们( -
用于替换),然后停止任何进一步的改写( [L]
)
A quick explanation: this matches any URLs that begin with /blog/
or /phpmyadmin/
and doesn't rewrite them (-
for the replacement), and then stops any further rewriting ([L]
).
的 previous答案:的
您重写规则相冲突的,一开始。此外,在此刻,的RewriteCond只适用于第一个规则。此外,最终的规则,因为这一切都匹配之前规则的忽略。你可能想是这样的:
Your rewrite rules are conflicting, for a start. Also, at the moment, the RewriteCond only applies to the first rule. Also, the final rule is ignored because of the rule before it matching everything. You may want something like this:
RewriteRule ^/blog/(.*)$ /index.php?url=$1 [QSA,L]
我假设你只是试图从 /博客/富/条
所有URL重写 /index.php?url=foo %2fbar
?如果不是,请解释一下你试图完成什么,我将修改我的答案。
as I assume you're just trying to rewrite all URLs from /blog/foo/bar
to /index.php?url=foo%2fbar
? If not, please explain what you're trying to accomplish and I'll edit my answer.
这篇关于需要与Apache重写问题帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!