index.php在我使用https时不会删除,但它适用于http。我需要做的是我的网站正常工作,例如它可以在 http 和 https 上运行。任何遇到同样问题的人都帮助我解决这个问题。
例如:在 http 中
- http://xyz.mydomain.com/users/login//工作正常
- 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//工作正常
我的访问代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
配置.php我的基本网址设置为
$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>
快乐编码:)