Himanshu97
Himanshu97

Reputation: 541

Why Yii actions give 404 error when moved to https://

i have my project built over http:// using Yii framework and PHP.. recently i installed self signed certificates, to test it over HTTPS://

only problem is, apart from index.php no other actions (Yii controllers) can be accessed over https:// it always returns with 404 not found. is there a change in the framework or some entry i have to make in order to make it work over SSL.

project is working all fine when i use, http:// and i can access index page using https:// so maybe i am doing something right, and something wrong at the same time

here are changes that i made in my code..

in index.php

require_once('require_ssl.php');

here is require_ssl.php

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

and this is my .htacces file

    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

Upvotes: 1

Views: 988

Answers (1)

Himanshu97
Himanshu97

Reputation: 541

and the answer is, same entries were also to be made in,

default-SSL.conf file.. coz overriding was not happening when site was running over https:// thats why there was a 404 error.

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

Upvotes: 1

Related Questions