在php codeigniter中将简单url重定向到https
我有一个网站,它的url目前是thereviewplace.com。我有ssl证书,所以我想将这个url重定向到我有serch over net,我已经尝试了很多htaccess代码,比如在php codeigniter中将简单url重定向到https,codeigniter,https,Codeigniter,Https,我有一个网站,它的url目前是thereviewplace.com。我有ssl证书,所以我想将这个url重定向到我有serch over net,我已经尝试了很多htaccess代码,比如 RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://thereviewplace.com/$1 [R,L] 但它会产生类似于 “页面未正确重定向” 请提供解决方案 在config/base\u url()中设
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://thereviewplace.com/$1 [R,L]
但它会产生类似于
“页面未正确重定向”
请提供解决方案
在config/base\u url()中设置如下https://www.thereviewplace.com
因为在你的页面源代码中
如果我像http://www.thereviewplace.com
工作正常
在config/base\u url()中设置如下https://www.thereviewplace.com
因为在你的页面源代码中
如果我像
http://www.thereviewplace.com
工作正常在您的代码点火器设置中执行以下操作:
$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>
NameVirtualHost*:80
ServerName mysite.example.com
DocumentRoot/usr/local/apache2/htdocs
重定向永久/安全https://mysite.example.com/secure
ServerName mysite.example.com
DocumentRoot/usr/local/apache2/htdocs
斯伦金安
#等等。。。
来源
在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>
NameVirtualHost*:80
ServerName mysite.example.com
DocumentRoot/usr/local/apache2/htdocs
重定向永久/安全https://mysite.example.com/secure
ServerName mysite.example.com
DocumentRoot/usr/local/apache2/htdocs
斯伦金安
#等等。。。
来源
把这个放进你的电脑里
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/';
把这个放进你的电脑里
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]
在您的应用程序/config/config.php中编辑以下内容
$config['base_url'] = 'https://thereviewplace.com/';
首先设置
$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]
首先设置
$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]
使用http在配置文件中设置base_url,然后尝试此.htaccess文件
重新启动发动机
# 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]
使用http在配置文件中设置base\u url,然后尝试此.htaccess文件
重新启动发动机
# 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]
谢谢大家给出了最好的答案 我有我的问题解决方案。下面是我在我的网站上使用的代码 重新启动发动机 RewriteCond%{HTTP_HOST}^thereviewplace.com[NC] 重写规则^(.*)$$1[R=301,L]
现在没有任何错误出现,并且工作正常。感谢大家提供的最佳答案 我有我的问题解决方案。下面是我在我的网站上使用的代码 重新启动发动机 RewriteCond%{HTTP_HOST}^thereviewplace.com[NC] 重写规则^(.*)$$1[R=301,L]
现在没有出现任何错误并且工作正常。我也尝试过将基本url更改为但不工作。我也尝试过将基本url更改为但不工作。您的服务器上的httpd.conf在哪里?在Linux中,它通常位于/etc/apache2/conf/httpd.conf。。。在Windows上,它将位于安装Apache的位置。事实上,我无权更新它。那么我可以从根文件夹更新吗?如果您无法更新httpd.conf,请使用答案中的第一个示例更新您的
.htaccess
文件。如果您有权访问httpd.conf,您可以使用第二个示例更新该文件/谢谢我在#上的httaces file RewriteEngine中添加了以下代码,这将启用RewriteCond%{HTTPS}的重写功能=在#上,此检查以确保连接尚未HTTPS重写规则^/?(*)HTTPS://%{SERVER_NAME}/$1[R,L]#此规则将用户从其原始位置重定向到使用HTTPS的相同位置i、 e.to#前导斜杠是可选的,因此可以在httpd.conf#或.htaccess上下文中使用:(但是仍然有这个网页有一个重定向循环ERR_TOO_MANY_redirects在你的服务器上有httpd.conf吗?在Linux中它通常位于/etc/apache2/conf/httpd.conf…在Windows上它将位于安装Apache的位置。实际上我没有更新它的权限。所以我可以从我的根文件夹进行更新吗?)如果你你无法更新你的httpd.conf,请使用答案中的第一个示例更新你的.htaccess
文件。如果你有权访问你的httpd.conf,你可以使用第二个示例更新该文件/谢谢我在#上的httacess file RewriteEngine中添加了以下代码;这将启用RewriteCond%{HTTPS}的重写功能!=on#此检查以确保连接尚未HTTPS重写规则^/?(*)HTTPS://%{SERVER_NAME}/$1[R,L]#此规则将用户从其原始位置重定向到使用HTTPS的相同位置。#即,到#前导斜杠是可选的,以便在httpd.conf#或.htaccess上下文中工作:(但仍然存在此网页有重定向循环错误\u太多\u重定向。)