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>
网上找了好多资料,求教各位大神怎么解决,不胜感激
应该是写在配置文件里面弄吧server
{
listen 80;
server_name jcwxcc.com www.jcwxcc.com;
rewrite ^(.*) https://www.jcwxcc.com$1 permanent; # abc.com对应修改为您自已的域名
}
nginx 的 供参考
还要注意当运行一个 HTTPS 服务器时,需要添加 fastcgi_param HTTPS on; 一行, 这样 Yii 才能正确地判断连接是否安全。
这是手册里的一句话对你应该有用