0
votes

Obtenir le serveur de formulaire URL complet

Je veux obtenir le côté du serveur de formulaire URL.

J'utilise cette demande d'appel à AJAX au serveur: xxx

si j'utilise $ $ _Server ['demande_uri'] (dans func_infos.php) pour obtenir l'URL que cela me donne: comprend / pages_includes / func_infos.php .

Je veux obtenir comme URL: http: //localhost/insc/web_/view_page.php? Id_page = 10 .

Comment puis-je obtenir l'URL nécessaire?


3 Réponses :


1
votes

Utilisez cette approche pour JavaScript: xxx

pour php: xxx


0 commentaires

0
votes

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


0 commentaires

1
votes

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


0 commentaires