1

I have a website with some custom api endpoints. I recently installed SSL and configured the website to redirect http visitors to https. I usually do this with the Really Simple SSL plugin.

The https version of the api works as intended. However, for historic reasons, i still have so support for some time an old application which uses the http api endpoint. Calling the http api result in a 404 error.

So i tried to disable the .htaccess automatic rewrite of the plugin and write it by hand, this is what wrote:

<IfModule mod_rewrite.c>
   RewriteCond %{HTTPS} !=on
   RewriteCond %{REQUEST_URI} !^/wp-json.*
   RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>


# 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 WordPress

When I do this the website pages get redirected to https correctly. The HTTPS API works, but the HTTP API version gets oddly redirected to the homepage.

Any help on this?

2
  • There's nothing in the .htaccess file you posted that would result in a redirect to the homepage. Have you cleared the browser cache to make sure you aren't seeing a cached redirect? How does the "Really Simple SSL plugin" perform the HTTP to HTTPS redirect?
    – DocRoot
    Commented Jun 7, 2018 at 18:21
  • Never found a solution, I made a custom redirect from the homepage only and then deprecated the non-secure apis.
    – marek.m
    Commented May 2, 2019 at 13:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.