HTTP to HTTPs?
-
I can’t find a way to automatically redirect all http links to the https version of it.
This is my current cache:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPressThanks
-
I am assuming that you are changing these lines in the .htaccess area?
Assuming this, I would suggest adding this redirect in a separate # block. If you keep it in the WordPress # section, it will be removed anytime you have to rebuild the Permalinks data.
The 301 redirect flag indicates that it is permanent redirect.
# BEGIN Custom # Redirect a user from HTTP to HTTPS RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # END CustomHave you checked your domain is ssl certified or not if yes then you should add the following code in your .htaccess file. i hope it will help you.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]Thanks for the suggestion, guys. It didn’t work yet.
On Chrome, it gives the TOO_MANY_REDIRECTIONS error message.
Also, the website is ssl certified, @mithilesh Kumar.
With the original .htcaccess, this is what happens:
https://www.dukescasino.com/ – works perfectly
https://dukescasino.com/ – redirects to the above which is greatThe two options below loads fine, but it should redirect to the https version:
http://www.dukescasino.com/
http://dukescasino.com/Here is the full .htcaccess file that gives the error message:
<IfModule mod_rewrite.c> RewriteEngine On # BEGIN WordPress RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # BEGIN Custom # Redirect a user from HTTP to HTTPS RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # END Custom </IfModule>have u using woocommerce???
Nope. No e-commerce at all.
Here is the list of active plugins. I don’t think they are related with the issue but never know:
Advanced Custom Fields All In One SEO Pack Bop Search Box Item Type For Nav Menus Contact Form 7 Disable Comments Google XML Sitemaps Jetpack by WordPress.com Search & Filter Slider WD TablePress UpdraftPlus - Backup/Restore Wordfence Security WPide WP Smush WP Super CacheFull detailed discussion with tests on stackoverflow:
http://stackoverflow.com/questions/32049820/use-htaccess-to-redirect-http-to-https
I am taking a guess here, but it could have to do with the entire code being within the <IfModule mod_rewrite.c> block. Which if the first is the case, then the entire block may be being skipped over, ignoring any redirect. This makes sense because the HTTP isn’t changing to HTTPS.
Also, I suggest adding “# END SECTION” to each # section. There are some plugins that change the .htaccess, and (as far as I know) they add code based on defined # sections.
I am not sure what is going on with this rule:
RewriteRule ^index\.php$ - [L]It’s not being impacted by any condition above it, so it could be causing some problems (esp since it’s flagged as Last). Make sure that those lines are the WordPress default code (I don’t know what that is, as I use optimized code instead, so this may in fact be right, idk).
# BEGIN CRISCMAIA CUSTOM RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # END CRISCMAIA CUSTOM # BEGIN WordPress RewriteEngine on RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPressThanks for the suggestion, unfortunately, it didn’t work yet. I keep getting the ERR_TOO_MANY_REDIRECTS.
According to the WP documentation, here is the defautl .htaccess file:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPresswhats your domain, can you tell me the url
will you plz deactivate tablepress and super cache plugin and please check wp-config.php file ::
define(‘FORCE_SSL_ADMIN’, true)
Problem solved!
Final .htaccess:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{ENV:HTTPS} !=on RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] # BEGIN WordPress RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>Topic closed.
Could you show me how you replace your site name in this code?
Sure! You have to find the .htaccess file on the root of your website (via FTP).
Download it to your pc, make a copy of it (just for backup purpose), open it with a Notepad (or similar), copy/paste the code, save the file, upload it back to the server overwriting the current file.
That should do.
The topic ‘HTTP to HTTPs?’ is closed to new replies.