Reputation: 141
I have one website its url is currently thereviewplace.com. i have ssl certificate so i want to redirect this url to https://thereviewplace.com i have serch over net and i have tried many htaccess code like
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://thereviewplace.com/$1 [R,L]
But it gives error like "The page isn't redirecting properly"
Please provide solution.
Upvotes: 1
Views: 3313
Reputation: 4760
In your CodeIgniter settings do this:
$config['base_url'] = "";
You need to check the %{HTTPS}
variable:
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
Source
Although the recommended way is to put this in your 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>
Source
Upvotes: 1
Reputation: 141
Thank you all for your best answers.
I got my questions solution. And below is the code which i have used in my website.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^thereviewplace.com [NC]
RewriteRule ^(.*)$ https://www.thereviewplace.com/$1 [R=301,L]
Now there is no any error is coming and working properly.
Upvotes: 0
Reputation: 1423
Set base_url in config file with http and try this .htaccess file
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]
Upvotes: 0
Reputation: 887
first of all set
$config['base_url'] = "";
Codeigniter will automatically get it.
Second, use this rule in .htaccess
file :
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]
Upvotes: 2
Reputation: 289
put this in your 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]
and in you application/config/config.php edit the follwoing
$config['base_url'] = 'https://thereviewplace.com/';
Upvotes: 0
Reputation: 38609
In
config/base_url()
set like thishttps://www.thereviewplace.com
Because in your page source
If i access page like http://www.thereviewplace.com
works fine
Upvotes: 1