Apache:帮助禁用子域

时间:2018-03-25 13:03:50

标签: apache .htaccess yii dns

我已被移交给Apache网络服务器 服务器版本:Apache / 2.4.7(Ubuntu) 运行Yii(1.1.14)网站。

问题是我可以访问w.site.com和ww.site.com,我不知道这个服务器名称或别名的定义。 在site-available中,.conf文件如下所示:

<VirtualHost 100.100.200.100:80>
  ServerName site.dk
  ServerAlias www.site.dk
  ServerAlias webmail.site.dk
  ServerAlias admin.site.dk

  DocumentRoot /home/site/apps/site/public_html
  ErrorLog /var/log/virtualmin/site.dk_error_log
  CustomLog /var/log/virtualmin/site.dk_access_log combined
  ScriptAlias /cgi-bin/ /home/site/cgi-bin/
  DirectoryIndex index.html index.htm index.php index.php4 index.php5

  #Redirect 301 w.site.dk http://www.site.dk
  #Redirect 301 ww.site.dk http://www.site.dk

  <Directory /home/site/apps/site/public_html>
    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
    AddType application/x-httpd-php .php
    AddHandler fcgid-script .php
    AddHandler fcgid-script .php5
    FCGIWrapper /home/site/fcgi-bin/php5.fcgi .php
    FCGIWrapper /home/site/fcgi-bin/php5.fcgi .php5
    RewriteEngine On
    #RewriteCond %{HTTP_HOST} ^w.site.dk [NC]
    #RewriteRule ^(.*)$ http://site.dk/$1 [L,R=301]
 </Directory>
 <Directory /home/site/cgi-bin>
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
 </Directory>

 RewriteEngine on
 #Redirect permanent w.site.dk http://www.site.dk
 #Redirect permanent ww.site.dk http://www.site.dk
 #RewriteCond %{HTTP_HOST} !^(www*).site\.dk [NC]
 #RewriteRule (.*) http://www.site.dk/$1 [L,R=301]

 RewriteCond %{HTTP_HOST} =webmail.site.dk
 RewriteCond %{HTTP_HOST} =admin.site.dk
 RemoveHandler .php
 RemoveHandler .php5
 php_admin_value engine Off
 IPCCommTimeout 31
 FcgidMaxRequestLen 1073741824
 Alias /blog /home/site/apps/wordpress

 <Directory "/home/site/apps/wordpress">
    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    allow from all
    AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
    Require all granted
    AddType application/x-httpd-php .php
    AddHandler fcgid-script .php
    AddHandler fcgid-script .php5
    FCGIWrapper /home/site/fcgi-bin/php5.fcgi .php
    FCGIWrapper /home/site/fcgi-bin/php5.fcgi .php5
  </Directory>

  SuexecUserGroup "#1000" "#1000"
  RewriteCond %{SERVER_NAME} =webmail.site.dk [OR]
  RewriteCond %{SERVER_NAME} =site.dk [OR]
  RewriteCond %{SERVER_NAME} =www.site.dk [OR]
  RewriteCond %{SERVER_NAME} =admin.site.dk
</VirtualHost>

我已经尝试将w.site和ww.site重定向到www.site,正如您在注释掉的Redirect和RewriteCond中看到的那样,但似乎没有任何努力。

我不知道它是否是.htaccess文件呢?

./的public_html / htaccess的

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.site\.dk$ [NC]
RewriteRule ^(.*) http://site.dk/$1 [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\d*)$ /p/$1 [R=301,L]

RewriteCond %{REQUEST_URI} !^/dj-mobil/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^dj-(.*)$ /p/dj-$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mobildiskotek-(.*)$ /p/mobildiskotek-$1 [R=301,L]

RewriteRule . index-test.php

## Forward to Yii
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php 

如果我做了apachectl -S我得到:

VirtualHost configuration:
139.164.505.166:80     site.dk (/etc/apache2/sites-enabled/0-site.dk.conf:1)
139.164.505.166:443    wmail.site.dk (/etc/apache2/sites-enabled/wmail.site.dk.conf:40)
[2a01:7e20::f03c:96ff:fe27:90ac]:443 wmail.site.dk (/etc/apache2/sites-enabled/wmail.site.dk.conf:40)
 *:80                   is a NameVirtualHost
 default server cloud.site.dk (/etc/apache2/sites-enabled/000-default.conf:1)
 port 80 namevhost cloud.site.dk (/etc/apache2/sites-enabled/000-default.conf:1)
 port 80 namevhost wmail.site.dk (/etc/apache2/sites-enabled/wmail.site.dk.conf:1)
 alias www.wmail.site.dk
 alias webmail.wmail.site.dk
 alias admin.wmail.site.dk

我迷路了,甚至无法从奇怪的w重定向。 pefixes。任何人都可以帮助解决任何问题吗? 提前致谢!

1 个答案:

答案 0 :(得分:1)

任何一组中首次列出的VirtualHost都是&#34;默认&#34;对于那个IP:PORT。这就是apachectl -S试图告诉你的。

如果您想要捕获任何与您明确列出的主机名不匹配的传入主机名,只需在第二个vhost中定义您的真实内容(在类似debian的操作系统上,使用排序的网站 - 可用/ * .conf)