is this bulletproof to get the url with alias

2019-08-06 22:44发布

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"];

标签: php apache http
1条回答
欢心
2楼-- · 2019-08-06 23:26

I use:

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

Example Output:

https://example.com/alias-no-extension?query=1
查看更多
登录 后发表回答