开发者

mod_rewrite rule not working

开发者 https://www.devze.com 2022-12-11 12:17 出处:网络
I have the following rules in my htaccess: RewriteRule ^([^/.]+)/?$ list.php?categoryShortForm=$1&locationShortForm=world[QSA]

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]

In my localhost (win开发者_运维百科dows, xampp), it all works fine. In my real server (linux, apache) the first 2 rules work fine, but not there 3rd one.

For example:

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

Any idea??


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.


I am a little unclear on how your working URL is supposed to actually work. All three of your patterns start with "one or more non-slash, non-period characters" ([^/.]+), but URLs going into the pattern matching start with slashes: "/plastic-surgery/california-usa/".

Have you turned on mod_rewrite logging and checked out what mod_rewrite is actually doing?

  RewriteLog "/tmp/rewrite.log"
  RewriteLogLevel 9
0

精彩评论

暂无评论...
验证码 换一张
取 消