开发者

RewriteRule not working

This is the contents of my .htaccess file:

RewriteEngine on
RewriteRule ^开发者_StackOverflow社区upload$ upload.php
RewriteRule ^/(\d+)/?.*$ /view.php?id=$1 [L]

The first rule successfully works. When I navigate to http://localhost/upload it shows the upload.php page.

The second rule however, does not. When I browse to: http://localhost/1234/some-string I get a 404 error. It's meant to show this page: http://localhost/view.php?id=1234.

Hopefully you can see what I'm trying to do with the rule, I want the last string on the end of the URL to be completely ignored, and take the 1234 as a parameter for view.php.

Can anyone spot why this isn't working? I've tried everything I can think of, but to no success. Thanks!


it will be trying to find the directory /1234/ and failing. change the / to a - and it should work

EDIT: got that completely wrong ... it's actually that you have a / at the beginning of your pattern, whereas MOD_REWRITE receives the path without the first slash.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜