我有一个网站部署,使用kohana和URL重写,使URL更加宁静。 这工作正常。
我还将Moodle安装在同一台服务器的子目录中,并为此目录定义了一个子域。 所以Moodle安装在名为students的目录下,子域名为students.example.com。 这也工作正常。
我现在正在尝试安装我只需要在子域上的SSL证书。 我有一个Comodo通配符证书,所以它应该能够与子域一起工作。 当我使用https://example.com它工作正常,所以我可以看到SSL证书有效。 但是,当我尝试https://students.example.com它redirect到主站点。 http://students.example.com虽然工作正常。
适用于kohana重写规则的.htaccess文件是:
# Use PHP5.4 Single php.ini as default AddHandler application/x-httpd-php54s .php # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect hidden files from being viewed <Files .*> Order Deny,Allow Deny From All </Files> # Protect application and system files from being viewed RewriteRule ^(?:application|modules|system)\b index.php/$0 [L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT] Options -Indexes
根据文档,我将需要为子域添加以下规则:
#.htaccess WildCard SSL RewriteCond %{HTTP_HOST} ^students.example.com$ RewriteCond %{REQUEST_URI} !^/students/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /students/$1 RewriteCond %{HTTP_HOST} ^students.example.com$ RewriteRule ^(/)?$ students/index.php [L]
我尝试添加这个作为第一条规则,并作为第二条规则,但都没有奏效。 我现在明白,我将不得不写一套新的规则去做我想做的事情。
任何build议如何做到这一点将不胜感激。 如果这有什么不同,这个网站是由Bluehost托pipe的。
我怀疑你可能有另一个问题。 一个HTTP请求看起来像这样:
GET /foo.php HTTP/1.1 Host: monkedung.example.com Keep-Alive: timeout=15 Connection: Keep-Alive
等等。当你使用SSL进行encryption时,GET行后的所有内容都被encryption,所以Apache无法知道你要求的是什么主机。 在不知道主机的情况下,无法知道使用哪个证书来解密请求。 它也不知道要redirect到哪个目录,使用哪个.htaccess文件或主机确定的其他东西。 为此,AFAIK每个IP地址只能使用一个SSL主机。
我会尝试设置
students.example.com
作为默认的apache域名和example.com,如果这是你唯一想要使用ssl的。 我也会打开你的重写规则的debugging,所以你可以看到他们是否实际上是射击。 如果问题是上面提到的ssl问题,我怀疑你甚至没有那么远。
希望这可以帮助。
看起来您正尝试在相同的IP地址上托pipeexample.com和students.example.com。 如果您使用的是常规HTTP,那么这很好,但如果您使用的是HTTPS(端口443),那么您需要在不同的IP地址上提供此服务。
<VirtualHost *:80> DocumentRoot /var/www/example.com ServerName example.com </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/students.example.com ServerName students.example.com </VirtualHost> <VirtualHost 192.168.1.10:443> DocumentRoot /var/www/example.com ServerName example.com SSLEngine on SSLCertificateFile /path/to/example.com.cert SSLCertificateKeyFile /path/to/example.com.key </VirtualHost> <VirtualHost 192.168.1.11:443> DocumentRoot /var/www/students.example.com ServerName students.example.com SSLEngine on SSLCertificateFile /path/to/example.com.cert SSLCertificateKeyFile /path/to/example.com.key </VirtualHost>
您是否在SSL切换之后在moodle中查看了您的config.php?
请注意,你的$CFG->wwwroot现在已经改变了。 它应该是http://students.example.com