我在 IP XXX.XX.XXX.XXX 上有一个 Laravel PHP 和 AngularJS Web 应用程序,当我加载任何一个IP 或任何子域名会加载var/www/html/example/application
文件夹。例如 random.example.com 将指向该文件夹或https://XXX.XX.XXX.XXX将指向该文件夹。
当我将不同的域指向非服务器时,example.com
不会发生这种情况。
然而,我的问题是,我不明白为什么。我本以为预期的行为是只有 subdomain.example.com 会指向它。服务器上是否还有其他可能导致这种情况的地方我应该留意?
以下是example.conf
我在 /etc/apache2/sites-enabled 中使用的文件
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName subdomain.example.com
Alias /api /var/www/html/example/public
<Directory /var/www/html/example/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
DocumentRoot /var/www/html/example/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/STAR_example_com.crt
SSLCertificateKeyFile /etc/ssl/example.com.key
SSLCertificateChainFile /etc/ssl/STAR_example_com.ca-bundle
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName subdomain.example.com
Alias /api /var/www/html/example/public
<Directory /var/www/html/example/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
DocumentRoot /var/www/html/example/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSLEngine on
# SSLCertificateFile /etc/ssl/STAR_example_com.crt
# SSLCertificateKeyFile /etc/ssl/example.com.key
# SSLCertificateChainFile /etc/ssl/STAR_example_com.ca-bundle
</VirtualHost>
这是 /etc/apache2/sites-available 中的 000-default.conf 文件
<VirtualHost *:80>
#Redirect 403 /
#ErrorDocument 403 "Not allowed"
#Redirect 403 /
#ErrorDocument 403 "Not allowed"
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^(.+)\.oldexample\.ie$
RewriteRule ^(.*)$ https://%1.example.com$1 [R=302,L]
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
和 default-ssl.conf 在同一个目录中
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>