I have a website built with WordPress cms, i want to add https:// on my contact page by htaccess file of website. I have try different think but i an not able to do it. Here is the site link
Please share if have any idea!.
If you have https enabled for your domain, it would be a good idea to use it for the entire website, not just for one/some pages only.
To redirect all existing pages from http to HTTPS, you can use the following .htaccess code snippet:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]
</IfModule>
In your .htaccess - add this logic.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} contact
RewriteRule ^(.*)$ https://alacartesites.com/contact/$1 [R,L]
Ref: http://www.inmotionhosting.com/support/website/ssl/how-to-force-https-using-the-htaccess-file, it worked for me. I verified. Please use the below one.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(contact|contact/)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Related
Problem
Using .htaccess to force HTTPs on my Wordpress site does not work
Tried solution
On my Wordpress site I have the following .htaccess code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
But to force using HTTPs I'am trying to replace it with this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} mydomain\.dk [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.dk/$1 [R,L]
</IfModule>
Result
The website is no longer working (here is the website response):
This page isn’t working
www.mydomain.dk redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
Questions
Why can't I force using HTTPs on my Wordpress website?
What can I do to make it work?
Best regards, Henning
Before trying the surggested solutions - I tried to change the URL in the Wordpress settings to HTTPS and now it works.
Thanks for taking the time to answer my question, I was just about to try the Really Simple SSL plugin.
If your web server is running Apache, you can redirect all HTTP traffic to HTTPS by returning to the default .htaccess configuration and than adding the following code to your .htaccess file.
This is also the recommended method for redirecting WordPress to Apache:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
However, probably the easiest way to implement HTTPS on your WordPress site would be to install the following plugin:
https://wordpress.org/plugins/really-simple-ssl/
I am trying to force domain URL to use www always in WordPress Multisite.
For example if some one type abc.com then it should be redirect automatically to www.abc.com
I have used the following rules in htaccess but it works only for main domain in WordPress Multisite and not for other sub domains.
# Canonical https/www
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
So any help on this, is highly appreciated in advance.
Can you try this ?
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
I have a Wordpress website and to force all traffics over HTTPS, I 've used the code below in .htaccess file:
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Although, I can visit website on https:// mode well, and there is not any other issue on the certificate, any redirect from http:// to https:// does not happen! May you tell me what is the problem?
Note: All other htaccess conditions and rules are working.
This is my working solution to redirect all http pages to https at the very top of my WordPress .htaccess file and in any case before # BEGIN WordPress directives.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# # Redirection vers HTTPS
RewriteCond %{SERVER_PORT} ^80$ [OR]
RewriteCond %{HTTPS} =off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
#
</IfModule>
I'm trying to redirect and entire wordpress site to a new domain EXCEPT one blog post, and the admin pages.
I've searched this site multiple times for various fixes, and across google searches. nothing has worked yet.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/blog-post-I-want-to-stay-on-old-domain/
RewriteCond %{REQUEST_URI} !=/wp-login.php
RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.*)$ https://www.newsite.com/$1 [R=301,L]
</IfModule>
I expected to be redirected with a full URL to a new domain, so oldsite.com/blog-post-1 would redirect to newsite.com/blog-post-1.
This works.
I expected the /wp-admin/ and the wp-login.php sections of the site to stay active without a redirect so I can continue editing the site if needed.
This works.
I expected oldsite.com/blog-post-I-want-to-stay-on-old-domain/ to not redirect, and be ignored, according to the ReWriteCond.
This does not work.
Instead it redirects to newsite.com/index.php and then newsite.com/
What have I done wrong?
Try this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !wp-login|wp-admin|blog-post-I-want-to-stay-on-old-domain
RewriteRule ^(.*)$ https://www.newsite.com/$1 [R=301,L]
</IfModule>
My Wordpress site's URL is set to HTTPS in the WP settings. If you type domain.com, it redirects to www.domain.com. If you click on the logo, it'll take you to https:/www.domain.com. I'd like https to be enabled by default on all pages.
I tried using this as Brandozz recommended and it turns out my caching plugin as well but it keeps causing the loop error.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
My server used Nginx. The caching plugin is recommending adding a few lines of code but I'm not sure where or how. See http://docs.wp-rocket.me/article/36-fix-for-ssl-redirection-issue.. Cloudways is my host and I'm on a DigitalOcean server.
Here is what I'm currently using to redirect everything to https
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]