advance版下的apache配置.htaccess使http转向https [ 2.0 版本 ]
yii2框架的advance版,框架开启了URL美化:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules'=>[
"<controller:\w+>/<id:\d+>"=>"<controller>/view",
"<controller:\w+>/<action:\w+>"=>"<controller>/<action>"
],
],
使用的apache服务器,项目backend目录的web下配置.htaccess:
原来的配置是http访问的方式,可以正常访问:
Options +FollowSymlinks
IndexIgnore */*
RewriteEngine On
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
RewriteRule \.svn\/ /404.html
RewriteRule \.git\/ /404.html
加了阿里云的免费ssl证书后,修改为如下后访问跳转到https了却是404:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
网上找了好多资料,求教各位大神怎么解决,不胜感激
三亩地 补充于 2018-01-15 15:01
ssl证书配置是:**
Listen 443
<VirtualHost *:443>
DocumentRoot "C:\WWW\demo1\backend\web"
ServerName test.ssl1.com
ServerAlias test.ssl1.com
<Directory "C:\WWW\demo1\backend\web">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLHonorCipherOrder on
SSLCertificateFile "C:\Program Files\Apache\cert\ssl1\public.pem"
SSLCertificateKeyFile "C:\Program Files\Apache\cert\ssl1\214389064350038.key"
SSLCertificateChainFile "C:\Program Files\Apache\cert\ssl1\chain.pem"
</VirtualHost>
三亩地 补充于 2018-01-17 12:15
web目录下的.htaccsee完整配置,不论是一级域名还是二级域名都可以访问,已经经过测试:
Options +FollowSymlinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
RewriteRule \.svn\/ /404.html
RewriteRule \.git\/ /404.html
最佳答案
其他 2 个回答
三亩地
注册时间:2017-06-08
最后登录:2018-01-25
在线时长:17小时5分
最后登录:2018-01-25
在线时长:17小时5分
- 粉丝3
- 金钱320
- 威望0
- 积分490