php - 为什么 Yii 操作在移动到 https ://时会出现 404 错误

标签 php apache ssl yii

我使用 Yii 框架和 PHP 在 http://上构建了我的项目。 最近我安装了自签名证书,通过 HTTPS 进行测试://

唯一的问题是,除了 index.php 之外,没有其他操作(Yii Controller )可以通过 https://访问,它总是返回 404 not found。框架是否有变化或我必须进行一些输入才能使其通过 SSL 工作。

当我使用 http://时项目工作正常 我可以使用 https://访问索引页面,所以也许我做对了,同时做错了

这是我在代码中所做的更改..

index.php

require_once('require_ssl.php');

这里是require_ssl.php

<?php
if(empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != "on")
{
    header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
    exit();
}
?>

这是我的 .htacces 文件

    Options +FollowSymLinks
    IndexIgnore */*
    <IfModule mod_rewrite.c>
    RewriteEngine on

    #use of SSl 
    RewriteCond %{SERVER_PORT} 80
    RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

    # 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
    </IfModule>

is there still something i am missing???

her is my 000-default.conf of Apache2

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride All                              
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All                                 
        Order allow,deny
        allow from all
    </Directory>


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

最佳答案

答案是,同样的条目也将在,

默认的 SSL.conf 文件.. 因为当网站在 https://上运行时没有发生覆盖,这就是出现 404 错误的原因。

   <Directory />
    Options FollowSymLinks
    AllowOverride All                              
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All                                 
    Order allow,deny
    allow from all
</Directory>

关于php - 为什么 Yii 操作在移动到 https ://时会出现 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23004205/

相关文章:

php - 将两个变量合并为一个

php "All authentication must be done over SSL"使用 SOAP

php - 水平递增循环到excel单元格PHP

linux - Apache 在查询时重定向到主 URL

ssl - 用于使用 Rest API 的 Nginx Mutual Auth

javascript - 只有 JQuery 可以与 FormData 一起使用吗?

php - UTF-8贯穿始终

javascript - 无法通过 xmlhttprequest 加载本地 xml 文件

ssl - 您是否应该提供一个 crt 文件来帮助人们验证您的 OAuth2 api 上的证书?

ssl - 在启用 SSL 的情况下启动 Tomcat 6 时出错