我有点卡住了,我确信这是一个微不足道的问题,但似乎找不到正确的解决方案。
我有一个本地开发服务器运行 apache2 w/mod_ssl & mod_rewrite。我创建了一个自签名证书并为 *:443 添加了相应的虚拟主机指令。我似乎遇到的问题是,现在我的 SSL 方面工作正常。当我说得正确时,我的意思是我可以在不添加 index.php 的情况下访问我网站的 https url(例如https://dev.mysite/),它可以很好地提取 index.php。
但是当我访问该站点的常规 http url 时,我必须输入 index.php 才能看到该站点。(例如http://dev.mysite/index.php)
我尝试将 DirectoryIndex 指令添加到 *:80 块,但这似乎仍然不起作用。
如果有帮助的话,下面是虚拟主机文件的内容;
ServerName dev.mysite
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/vhosts/bsah_dev/mysite
<Directory />
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/vhosts/bsah_dev/mysite/>
DirectoryIndex index.html index.htm index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/vhosts/bsah_dev/mysite
SSLEngine On
<Directory /var/www/vhosts/bsah_dev/mysite>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L]
</IfModule>
</Directory>
SSLOptions +StrictRequire
SSLCertificateFile /etc/apache2/ssl.crt/server.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/server.key
</VirtualHost>