0
  1. I want to redirect directory /api/ and everything after it to HTTPS. Everything else must redirect to HTTP if a visitor tries to visit something with HTTPS.

  2. I'd like WordPress to ignore the /api/ directory (and everything after it) from the current mod rewrite.

This is my current standard WordPress .htaccess:

# 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
Ryan Koehler
  • 193
  • 1
  • 8

2 Answers2

0

Have you tried adding :

RewriteCond %{REQUEST_URI} YourFolderName 
RewriteRule ^(.*)$ https://www.example.com/YourFolderName /$1 [R,L]

(Taken from HERE for more info)

Obmerk Kronen
  • 15,619
  • 16
  • 66
  • 105
0

Try this:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/api/ [NC]
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
John
  • 1
  • 1
  • 1
  • Good tip about the NC flag, but it doesn't seem to be doing anything. For example, when I visit `mysite.com/API/`, it only redirects to `mysite.com` – Ryan Koehler May 19 '12 at 11:21
  • Apache is case sensitive. /API/ and /api/ are not the same. You'd need to add another RewriteCon for that. – John May 19 '12 at 12:28
  • Also, put the https redirect lines ABOVE your standard Wordpress redirect lines. – John May 19 '12 at 12:45