Je veux obtenir le côté du serveur de formulaire URL.
J'utilise cette demande d'appel à AJAX au serveur: p> si j'utilise $ $ _Server ['demande_uri'] strong> (dans func_infos.php) pour obtenir l'URL que cela me donne: comprend / pages_includes / func_infos.php strong>. P> Je veux obtenir comme URL: Comment puis-je obtenir l'URL nécessaire? P> P>
3 Réponses :
Utilisez cette approche pour JavaScript: pour php: p>
Si vous souhaitez obtenir une URL complète ou que votre serveur prend en charge HTTP ou HTTPS, essayez
$link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
Vous pouvez utiliser le code suivant pour l'URL complète actuelle à l'aide de PHP
$pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; }
Veuillez vous reporter Stackoverflow.com/questions/1802954/.../ a>
Duplicaté possible Stackoverflow.com/questions/6768793/ Get-the-to-URL-in-php