无法加载资源:net :: ERR_NAME_NOT_RESOLVED - 在子域

时间:2015-12-20 12:21:36

标签: apache .htaccess subdomain

我想将我的工作网站移到像这样的子域

 web1.origdomain.com //working laravel
 web2.origdomain.com//working symfony
 web3.origdomain.com//not working plain html5

web1和web2带有.htaccess,而web3 .htaccess是硬编码的,这意味着来自Google的一些教程的复制粘贴.Well,web3在开发机器中完美运行。

 localhost:8096

实际上,如果我通过简单地暂时调整Apache2来移动它,那么web3将在生产中工作,类似

 origdomain.com

这就是我在Apache2中创建web3.conf的方式

<VirtualHost *:80>

    #ServerAdmin webmaster@localhost
    DocumentRoot /var/www/web3
    <Directory /var/www/web3/>
      AllowOverride all
      Require all granted
    </Directory>
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog /var/www/web3/log/error.log
    CustomLog /var/www/web3/log/access.log combined


</VirtualHost>

其他子域的配置方式与上面相同,但我很困惑为什么web3在这里不起作用。可能在这里错误地配置web3 .htaccess

<IfModule mod_rewrite.c>
 RewriteEngine On
 #RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . index.php [L]
</IfModule>

我也很困惑Apache2中的错误日志

 Sun Dec 20 17:36:45.958848 2015] [:error] [pid 4426] [client 124.83.19.163:58938] PHP Notice:  Undefined index: ALL_HTTP in /var/www/web3/app/detect.php on line 118

同样,如果它的位置为

,web3将完美运行
origdomain.com 

而不是子域

web3.origdomain.com

这是web3的结构

  web3
    app
        detect.php
    log
    web
        css
        js
        about.php
        index.php
    .htaccess
    index.php

你是如何解决这个问题的? 已启用mode_rewrite

1 个答案:

答案 0 :(得分:0)

我终于解决了。这就是我配置web3.conf的方式

<VirtualHost *:80>
  ServerName   web3.origdomain.com
  ServerAlias  web3.origdomain.com

 DirectoryIndex index.html index.php
 DocumentRoot /var/www/web3
 <Directory "/var/www/web3">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
 </Directory>

   .....
   .....
</VirtualHost>