本文介绍了mod_rewrite 规则不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 htaccess 中有以下规则:

I have the following rules in my htaccess:

RewriteRule ^([^/.]+)/?$ list.php?categoryShortForm=$1&locationShortForm=world      [QSA]
RewriteRule ^([^/.]+)/([^/.]+)/?$ list.php?categoryShortForm=$1&locationShortForm=$2    [QSA]
RewriteRule ^([^/.]+)/([^/.]+)/[^/.]*-p([0-9]+)/?$ view.php?categoryShortForm=$1&locationShortForm=$2&postingId=$3  [QSA]

在我的本地主机(windows、xampp)中,一切正常.在我的真实服务器(linux、apache)中,前 2 条规则工作正常,但没有第三条.

In my localhost (windows, xampp), it all works fine.In my real server (linux, apache) the first 2 rules work fine, but not there 3rd one.

例如:

/plastic-surgery/california-usa/ 工作正常,但/plastic-surgery/los-angeles-california-usa/test-1-p1 给我一个 404

/plastic-surgery/california-usa/ works fine, but/plastic-surgery/los-angeles-california-usa/test-1-p1 gives me a 404

有什么想法吗??

推荐答案

检查以确保您可以直接浏览到目标 URL.如果 mod_rewrite 正在重写一些不存在的东西,你会得到 404.这可能有助于将 mod_rewrite 的日志级别提高到一个较高的值,这样你就可以看到它正在重写的内容.

Check to make sure that you can browse directly to the target URLs. If mod_rewrite is rewriting onto something that doesn't exist, you'll get that 404. It might help to ratchet up mod_rewrite's log level to a high value, so you can see what it's rewriting to.

这篇关于mod_rewrite 规则不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 06:15