2016-08-29 4 views
0

私のローカル開発Laravelプロジェクトのwildcard subdomainxamppに作成しようとしています。これまで私はhostsファイルを変更し、自分のドメイン名の仮想ホストを作成することができました。ここでxampp localhostでワイルドカードサブドメインを作成します。

は私のホストは私はここに私のhttpd.confファイル

で仮想ホストを有効にしている

127.0.0.1 localhost 
127.0.1.1 lalit-Inspiron-3537 

127.0.0.1 mysite.local 


# The following lines are desirable for IPv6 capable hosts 
::1  ip6-localhost ip6-loopback 
fe00::0 ip6-localnet 
ff00::0 ip6-mcastprefix 
ff02::1 ip6-allnodes 
ff02: 

:2 ip6-allrouters 

ファイルである私のhttpd-vhosts.confファイル

# Virtual Hosts 
# 
# Required modules: mod_log_config 

# If you want to maintain multiple domains/hostnames on your 
# machine you can setup VirtualHost containers for them. Most configurations 
# use only name-based virtual hosts so the server doesn't need to worry about 
# IP addresses. This is indicated by the asterisks in the directives below. 
# 
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/> 
# for further details before you try to setup virtual hosts. 
# 
# You may use the command line option '-S' to verify your virtual host 
# configuration. 

# 
# VirtualHost example: 
# Almost any Apache directive may go into a VirtualHost container. 
# The first VirtualHost section is used for all requests that do not 
# match a ServerName or ServerAlias in any <VirtualHost> block. 
# 
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "/opt/lampp/docs/dummy-host.example.com" 
    ServerName dummy-host.example.com 
    ServerAlias www.dummy-host.example.com 
    ErrorLog "logs/dummy-host.example.com-error_log" 
    CustomLog "logs/dummy-host.example.com-access_log" common 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "/opt/lampp/docs/dummy-host2.example.com" 
    ServerName dummy-host2.example.com 
    ErrorLog "logs/dummy-host2.example.com-error_log" 
    CustomLog "logs/dummy-host2.example.com-access_log" common 
</VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot "/opt/lampp/htdocs/mysite/public" 
    ServerName mysite.local 
    ServerAlias *.mysite.local 
    <Directory "/opt/lampp/htdocs/mysite/public"> 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

である私は私のLaravelにアクセスすることができますプロジェクトはmysite.localです。しかし、私はsubdomain.mysite.localにアクセスしようとしたとき、私は

This site can’t be reached 

subdomain.mysite.local’s server DNS address could not be found. 
Try: 
Checking the connection 
Checking the proxy, firewall, and DNS configuration 
ERR_NAME_NOT_RESOLVED 

次のエラーを取得する誰もがこれで私を助けてくださいことはできますか?

答えて

1

解決策が見つかりました。ドメイン名はavahi-daemonで使用されているため、.localは使用できません。だから私は自分のドメイン名から.local

ホストファイルを変更し

127.0.0.1 localhost 
127.0.1.1 lalit-Inspiron-3537 

127.0.0.1 mysite.dev 

のhttpd-vhosts.confファイル

<VirtualHost *:80> 
    DocumentRoot "/opt/lampp/htdocs/mysite/public" 
    ServerName mysite.local 
    ServerAlias *.mysite.local 
    <Directory "/opt/lampp/htdocs/mysite/public"> 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

そして今、それは完璧に働いています。

+0

あなたの 'ServerName'と' ServerAlias'ディレクティブは 'mysite.local'を指しています。 – Doom5

+0

ああ、それがポイントだった。私はすべてのリクエストを同じディレクトリにリダイレクトしようとしていて、私の 'Laravel'プロジェクトの'サブドメイン 'のテキストに基づいて処理していました。 –

関連する問題