[英]Apache: Help disable subdomains
我已经交出了一个Apache Web服务器服务器版本:运行Yii(1.1.14)网站的Apache / 2.4.7(Ubuntu)。
问题是我可以访问w.site.com和ww.site.com,却不知道在何处定义此服务器名或别名。 在可用的站点中,.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。 固定点。 任何人都可以提供任何形式的修复帮助吗? 提前致谢!
任何集合中第一个列出的VirtualHost是该IP:PORT的“默认”。 那就是apachectl -S试图告诉您的。
如果您想捕获任何与您明确列出的主机名都不匹配的传入主机名,只需在第二个虚拟主机(在类似debian的操作系统上)中定义真实主机,方法是使用sites-available / * .conf)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.