【发布时间】:2018-03-25 13:03:49
【问题描述】:
我已收到一个 Apache Web 服务器 服务器版本:Apache/2.4.7 (Ubuntu) 运行 Yii (1.1.14) 网站。
问题是我可以访问 w.site.com 和 ww.site.com,但我不知道这个服务器名或别名是在哪里定义的。 在 sites-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 中重定向。前缀。任何人都可以帮助解决任何问题吗? 提前致谢!
【问题讨论】: