is this bulletproof to get the url with alias

2019-08-06 23:02发布

问题:

I am working with apache mod_alias so using HTTP_POST doesn't give me the alias plus with HTTPS it's not there. The below line seems to work but could it fail? I understood SERVER_NAME needs to be configured on server but provided it is this ok?

$site_url = $_SERVER["REQUEST_SCHEME"] . "://" . $_SERVER["SERVER_NAME"] . $_SERVER["CONTEXT_PREFIX"];

回答1:

I use:

$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']

Example Output:

https://example.com/alias-no-extension?query=1


标签: php apache http