开发者

URL routing/rewriting and compatibility with Nginx/Lighttpd

I'm writing a simple URL routing code based on using mod_rewrite to pass the URI as a GET parameter, like Drupal does. So I have the rule:

RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]

And the URL http://www.example.com/test/1 would give me "/test/1/" passed as value $_GET['q'], instead of the usual index.php/test/1 and having to extract开发者_StackOverflow中文版 that from $_SERVER['REQUEST_URI'].

The thing is, the mod_rewrite QSA flag allows me to still use query strings normally, which I find very useful for parameters like filters and pagination, like "/products/category/?pg=1".

Will this work the same on Nginx and Lighttpd servers? I'd like my code to be portable.

Thanks.


No, in either case you'll have to translate your rules into each server's specific syntax. Some links to get you started:

  • http://forums.digitalpoint.com/showthread.php?t=187965
  • http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModRewrite
  • https://serverfault.com/questions/24243/nginx-support-for-htaccess-rewrite-rules-differences-from-apache
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜