How can I find an application's base url?

后端 未结 11 1414
南方客
南方客 2020-12-16 01:35

I\'d like to find the base url of my application, so I can automatically reference other files in my application tree...

So given a file config.php in the base of my

11条回答
  •  清酒与你
    2020-12-16 02:12

    This works like a charm for me, anywhere I deploy, with or without rewrite rules:

    $baseDir = 'http://'.$_SERVER['HTTP_HOST'].(dirname($_SERVER['SCRIPT_NAME']) != '/' ? dirname($_SERVER["SCRIPT_NAME"]).'/' : '/');

提交回复
热议问题