0

Please give me a suggestion for my question.

when we set permalink in our site then the .htaccess code is

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] 

my site covert into http to https and i am adding below code to my .htaccess

RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_FILENAME} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_FILENAME} [L,R=301]

These codes are to redirect when we using www or and http then automatically convert into https:

So my problem is when we add this code to my .htaccess the post name or permalink is not working. home page was showing and also we can see the wp-admin pages, And all other links (example.www.xyz.com/register) not working. What i do? Please give your valuable suggestions and answers.

krish
  • 221
  • 1
  • 4
  • 20
  • 1
    Did you update the "WordPress Address (URL)" and "Site Address (URL)" in the general settings in wordpress to include https? – Howli Sep 18 '14 at 11:08
  • yes I am updates that all things... – krish Sep 18 '14 at 11:19
  • When you say all other links are not working, do you mean they show a 404 page or they are staying http? – Howli Sep 18 '14 at 11:24
  • Not Found The requested URL /documents/ was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. – krish Sep 18 '14 at 11:32

1 Answers1

0

Here is the correct syntax for your .htaccess - just replace domain.com with your actual website domain.

The first rewrite appends the www to all requests, the second rewrite appends the https to all requests.

Make sure to update your general settings in Wordpress as well, which you already commented that you did.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

RewriteCond %{SERVER_PORT} !443
RewriteRule ^(.*)$ https://www.domain.com/$1 [r=301,nc,L]
BradM
  • 646
  • 8
  • 18