118
119

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPで現在アクセスされているページのURLを取得する

Last updated at Posted at 2014-06-24

PHPで現在アクセスされているページのURLを取得する

■about

PHPで現在アクセスされているページのURLを取得する

■code

現在のページ自体

php
echo $_SERVER["REQUEST_URI"];

ホスト名も取得する場合

php
echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

プロトコルも取得する場合

php
echo (empty($_SERVER["HTTPS"]) ? "http://" : "https://") . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

■reference

PHPで現在アクセスされているページのURLを取得する - hoge256ブログ
http://www.hoge256.net/2010/06/519.html

$_SERVER変数|PHP情報|株式会社エン・PCサービス
http://www.en-pc.jp/php_server.php

$_SERVER
http://www.php.net//manual/ja/reserved.variables.server.php

118
119
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
118
119

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?