开发者

Match subdirectories in .htaccess

I am trying to match a URL like: http://xy.com/test/abcd to a php script named test.php

Here is my .htaccess

RewriteEngine on
RewriteB开发者_如何转开发ase /
RewriteRule ^test.* test.php [L]

This matches fine when I make a request with curl like:

curl http://xy.com/test123

But it the rule does not seem to match the following call (getting a http not found)

curl http://xy.com/test/1234

The latter case is what I want to implement a RESTful API. How do I have to define my rule to match this?


Not sure, but I think your rule in the second example tries to find /test/test.php

Try this:

RewriteEngine on
RewriteBase /
RewriteRule ^test.* /test.php [L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜