簡體   English   中英

index.php不刪除https CodeIgniter

[英]index.php not removing https CodeIgniter

我使用https時index.php並未刪除,但適用於http。 我需要做的是我的網站可以正常工作,例如可以同時在httphttps上運行 任何面對相同問題的人都可以幫助我解決此問題。

例如:在http

  1. http://xyz.mydomain.com/users/login //工作正常
  2. http://xyz.mydomain.com/index.php/users/login //工作正常

在https

1) https://xyz.mydomain.com/users/login //找不到404頁面
2) https://xyz.mydomain.com/index.php/users/login //運行正常

我的htaccess密碼

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

config.php我的基本URL設置為

$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

似乎您的主機文件有問題。 如果您使用的是apache,請更改您的主機文件,例如:

<VirtualHost *:443>
   ServerAdmin admin@example.com
   DocumentRoot /path
   ServerName xyz.mydomain.com
   ServerAlias www.xyz.mydomain.com

   SSLEngine On
   SSLOptions +StrictRequire
   SSLCertificateFile /path to ssl file/mydomain.crt
   SSLCertificateKeyFile /path to ssl file/mydomain.key
   SSLProtocol TLSv1
    <Directory "/path">
        Require all granted
        Options -FollowSymLinks -Includes -ExecCGI -Indexes
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    RewriteEngine On
</VirtualHost>

現在更改您的htaccess文件,如下所示:

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   RewriteEngine On
   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://xyz.mydomain.com/$1 [R=301,L]

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

快樂編碼:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM