如何使一个包罗万象的处理程序在.htaccess文件?

编程入门 行业动态 更新时间:2024-10-10 11:23:21
本文介绍了如何使一个包罗万象的处理程序在.htaccess文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在那捕捉一切眼福直到那时一个.htaccess文件的末尾来创建一个规则。

I want to create a rule at the end of an .htaccess file that catches everything that failed to match up until then.

我怎么能这样做?

P.S。我已经尝试了一切:)其实,我没有,但可以肯定,似乎喜欢它!的

更新:有些人回答与重写规则^ * $ 或等效的。 这不起作用!这将匹配的所有的,包括其他的好的网址。

Update: Some people are replying with RewriteRule ^.*$ or an equivalent. This does not work! It will match everything including the other 'good' URLs.

推荐答案

实际上有一些很好的答案,在这里了,但你有回应...

There are actually some good answers here already, but you have responded with...

但后来这匹配的一切,包括好东西。

But then this matches everything including the good stuff.

这是因为你没有告诉mod_rewrite的停止处理上的匹配。要做到这一点,用L标记每个规则,它告诉mod_rewrite的后说,如果这条规则匹配,停止处理任何进一步的规则。

This is because you aren't telling mod_rewrite to stop processing on a match. To do this, use the "L" tag after each rule, which tells mod_rewrite that "If this rule is matched, stop processing any further rules".

RewriteRule ^RSS/([^/\.]+)/?$ rss.php?Page=$1 [L]

您需要每个规则后,把这个。然后,当你把捕获的所有底,它只会在没有其他规则已被匹配命中。

You need to put this after EACH rule. Then, when you put the catch all at the end, it will only be hit if no other rule has been matched.

请注意:如果您还提供了未改写,如CSS,图片,JavaScript文件等资源 - 你是诚实最好不要再追所有,你会不会想重写它们的位置

NOTE: if you are ALSO serving up resources that are not rewritten, like CSS, images, javascript files - you are honestly better off not catching all as you wouldn't want to rewrite their locations.

更多推荐

如何使一个包罗万象的处理程序在.htaccess文件?

本文发布于:2023-11-28 08:47:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641725.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:包罗万象   文件   程序   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!