我有一个网站,其网址目前是thereviewplace.com。我有ssl证书,所以我想将这个网址重定向到https://thereviewplace.com我有网络,我已经尝试了许多htaccess代码,如
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://thereviewplace.com/$1 [R,L]
但它给出了错误 “页面没有正确重定向”
请提供解决方案。
答案 0 :(得分:2)
首先设置
$config['base_url'] = "";
Codeigniter会自动获取它。
其次,在.htaccess
文件中使用此规则:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTP_HOST} ^thereviewplace\.com$ [NC]
RewriteRule ^ https://thereviewplace.com%{REQUEST_URI} [R=301,L,NE]
答案 1 :(得分:1)
config/base_url()
设置如此https://www.thereviewplace.com
因为在您的页面来源
如果我访问http://www.thereviewplace.com
这样的页面工作正常
答案 2 :(得分:1)
在CodeIgniter设置中执行以下操作:
$config['base_url'] = "";
您需要检查%{HTTPS}
变量:
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
<强>来源
虽然推荐的方法是将它放在你的httpd.conf中:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.example.com
DocumentRoot /usr/local/apache2/htdocs
Redirect permanent /secure https://mysite.example.com/secure
</VirtualHost>
<VirtualHost _default_:443>
ServerName mysite.example.com
DocumentRoot /usr/local/apache2/htdocs
SSLEngine On
# etc...
</VirtualHost>
来源
答案 3 :(得分:0)
把它放在你的htaccess
中RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
并在您的application / config / config.php中编辑以下内容
$config['base_url'] = 'https://thereviewplace.com/';
答案 4 :(得分:0)
使用http在配置文件中设置base_url并尝试此.htaccess文件
RewriteEngine On
# Checks to see if the user is attempting to access a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
答案 5 :(得分:0)
谢谢大家的最佳答案。
我得到了我的问题解决方案。以下是我在我的网站上使用的代码。
上的RewriteEngine
RewriteCond%{HTTP_HOST} ^ thereviewplace.com [NC]
RewriteRule ^(。*)$ https://www.thereviewplace.com/ $ 1 [R = 301,L]
现在没有任何错误即将发生并正常工作。