Ubuntu 14.04 和服务器版本:Apache/2.4.16 (Ubuntu)
重定向规则不起作用,还是我遗漏了什么?当我在浏览器中输入时,我想使用https://teampass.domain.org, 但反而https://teampass.domain.org/teampass是唯一有效的 URL。我是否遗漏了什么?我该如何使用https://teampass.domain.org
更多 /etc/hosts
127.0.0.1 localhost
127.0.1.1 teampass
192.*.*.* teampass teampass.domain.org
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
更多 /etc/apache2/apache2.conf
ServerRoot "/etc/apache2"
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
<Directory /srv/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
# phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf
#load ssl module
#LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
更多/etc/apache2/sites-enabled/default-ssl.conf
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName teampass.domain.org
Serveralias www.teampass.domain.org
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCACertificateFile /etc/apache2/ssl/DigiCertCA
SSLCertificateFile /etc/apache2/ssl/star_domain_org
SSLCertificateKeyfile /etc/apache2/ssl/teampass.key
</VirtualHost>
更多/etc/apache2/sites-enabled/teampass.conf
<VirtualHost *:80>
ServerName teampass
Redirect permanent / https://teampass.domain.org/
ServerAdmin webmaster@localhost
ServerAlias www.teampass.domain.org
DocumentRoot /var/www/html/teampass
<Directory /var/www/html>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_rewrite.c>
# DO NOT REMOVE
RewriteOptions Inherit
</IfModule>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName teampass.domain.org
#ServerAlias www.teampass.domain.org
DocumentRoot /var/www/html/teampass
SSLCertificateFile /etc/apache2/ssl/star_domain_org
SSLCertificateKeyfile /etc/apache2/ssl/teampass.key
SSLCACertificateFile /etc/apache2/ssl/DigiCertCA
SSLEngine on
ErrorLog ${APACHE_LOG_DIR}/teampass_error.log
CustomLog ${APACHE_LOG_DIR}/teampass_access.log combined
<IfModule mod_rewrite.c>
# DO NOT REMOVE
RewriteOptions Inherit
</IfModule>
</VirtualHost>
答案1
您的网站的虚拟主机配置teampass.domain.org
将无法正常工作,因为它在同一个虚拟主机网站 (teampass.conf) 上同时具有 http 和 https。
teampass.domain.org
您的站点具有相同的服务器名称default-ssl
,这就是它可以运行并且您可以访问该站点但不能按照您想要的方式访问的原因,因为 DocumentRoot 指向/var/www/html
。
您可以将 DocumentRoot 更改为/var/www/html/teampass
default-ssl 文件中的并禁用其他虚拟主机文件。
或者,您需要为 http(80)和 https(ssl)创建两个不同的站点(使用两个 .conf 文件并启用它们)并禁用默认 ssl 站点。
您还需要纠正Options
apache 2.4 的一些语法。