htaccess redirects only with hard refresh

Viewed 43

I have a site in React.js on http://example.com, which uses wordpress API, which is located in example/wp subfolder. I have one htaccess in root folder:

# BEGIN redirection to https
   <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{HTTPS} !=on [NC]
      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
   </IfModule>
# END redirection to https

# BEGIN needed for client side routing
   <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-l
      RewriteRule ^.*$ / [L,QSA]
   </IfModule>
# END needed for client side routing

and in example/wp another htaccess:

# BEGIN WordPress
  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wp/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wp/index.php [L]
  </IfModule>
# END WordPress

The problem appeared after switching to https. When accessing example/wp/wp-admin I get notFound page from react app instead of wordpress admin panel. But when I hard refresh the page, I get redirected to the admin panel. Why? When I add

RewriteCond %{REQUEST_URI} ^.*/testingurl
RewriteRule ^(.*)$ https://someOtherexample.com [R=301,L]

I also get example/testingurl, but after hard refreshing I get redirected to someOtherexample.com. What I am missing?

0 Answers
Related