LoginSignup
3
7

More than 5 years have passed since last update.

Xamppでサブドメインを作る

Posted at

この頃のPHPとかの仕事ってドメインルートにソースをドチャーってする
パターンがおおいよね?
ドメインルートにドチャーってする必要があるならRubyの方が良いと思うのは
わたしだけですかねぇ~。
phpの良さである、自由さを殺すなら別の言語の方がもっと楽じゃねぇ~かな~と。

とは言っても仕事はありがたくさせて抱きます。
が!!サブドメインを作る必要があるので、ここに方法をまとめておきます

Xamppでサブドメインを作る

前提条件
* サブドメインのドキュメントルートは【htdocs】の中にしない。
* ドキュメントルートは【C:/xampp/test/】とする。
* サブドメインのURLは【test.localhost】とする。

Xamppのバーチャルドメインの設定ファイルを変更

対象ファイル
C:\xampp\apache\conf\extra\httpd-vhosts.conf

変更部分

##20行目
- ##NameVirtualHost *:80
+ NameVirtualHost *:80

一番下に以下を追加

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/xampp/test/"
    ServerName test.localhost
</VirtualHost>
<Directory "C:/xampp/test">
   Options Indexes MultiViews FollowSymLinks
   AllowOverride All
   Require all granted
</Directory>

Hostsファイルに追記

対象ファイル

C:\Windows\System32\drivers\etc\hosts

以下を追加

127.0.0.1       localhost
127.0.0.1       test.localhost

アパッチの再起動

3
7
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
3
7