[xampp]ローカルにサブドメイン切ったらaccess forbidden食らった
XREAのWebスペース上で開発することが多々あるのですが、たまにSAFE_MODEの弊害があってローカルのXAMPP / Windows 上での開発に移行したりします。
で、たまたまlocalhostのサブドメインをまだ切っていないマシンだったので、サブドメインを追加しようと思って、
C:\xampp\apache\conf\extra\httpd-vhosts.conf
のNameVirtualHostを有効にして、該当の<VirtualHost>ディレクティブを追加して、
C:\WINDOWS\system32\drivers\etc\hosts
に
127.0.0.1 localhost
127.0.0.1 subdomain1.localhost
を追加して見たのですが、早速 http://subdomain1.localhost/ にアクセスしても
Access forbidden!
といわれました。なぜだーとおもって昔のhttpd.confを覘いたら、<Directory>ディレクトリを書き忘れていたようです。
こういう細かいところのノウハウ(?)ってすぐに忘れちゃうんですよね。ってことで備忘録的に設定載せておきます。
httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DirectoryIndex index.php index.html
DocumentRoot “C:/path/to/subdomain1″
ServerName subdomain1.localhost
</VirtualHost><Directory “C:/path/to/subdomain1″>
order deny,allow
allow from ALL
</Directory><VirtualHost *:80>
DocumentRoot “C:/xampp/htdocs”
ServerName localhost
</VirtualHost>