URL重写:内部服务器错误 [英] URL rewrite : internal server error

查看:96
本文介绍了URL重写:内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Apache的重写规则有点问题

I have a little problem on Apache's rewrite rules

下面是我的规则

Options +FollowSymLinks
RewriteEngine On

RewriteBase /

RewriteRule query/(.*) /php/query.php?name=$1 [L]
RewriteRule page/(.*) /php/page.php?page=$1 [L]

它完美。但是,当我尝试添加下面的规则重写URL不是两个previous规则匹配

It works perfectly. But when I try to add the following rule to rewrite URL that not matches the two previous rules

RewriteRule .* /php/page.php?page=home

服务器响应内部服务器错误。为什么呢?

The server responds "Internal server error". Why ?

推荐答案

您可以使用 RewriteLog 来看看有什么happends,但即使有一个 [ L] 你可以肯定的一个rewrited URL总是在一套规则重新检查(这是调用内部重定向)。

You can use RewriteLog to see what happends, but even with a [L] you can be sure a rewrited url is always re-checked on the set of rules (this is call internal redirect).

所以增加一些的RewriteCond 这最后包罗万象,或prevent它内部重定向运行之前,这种方式:

So add some RewriteCond before this final catch-all, or prevent it to be running on internal redirects, this way:

RewriteCond %{ENV:REDIRECT_STATUS} ^$

您还可以添加 [NS] [nosubreq] 标签上最终包罗万象的,这不一样的。

You could also add the [NS] or [nosubreq] tag on your final catch-all, which does the same.

不过,preventing您的内部重定向规则也意味着它永远不会任何previous规则后应用,有一天你可能会想要它。所以,要小心旁边的规则。

But preventing your rule on internal redirection also means it will never be applied after any previous rule, and one day you might want it. So be careful with next rules.

这篇关于URL重写:内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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