php - Safely get the URL using $_SERVER -


i'm creating web app has many domains pointing same app, content displayed depend on domain used reach app.

i using

$_server['http_host'] 

to the domain , pull in correct content.

i read not safe, because

the client can set http_host arbitrary value wants

from get full url in php

how possible , how can protect against this?

using http_host in comparison statement such if fine. start run problems if use http_host data directly method requires sanitized data such sql query string, user malform header perform sql injection

if user malforms host header, , have if comparison such if($_server['http_host'] == 'www.google.com') changing not useful malicious user. if controlled context through header, not print anything

see answer more details


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -