Reputation: 31
I have a website build with React that uses Wordpress solely as a CMS. Routes are handled on the frontend side with react-router
but because of that, I cannot access my WordPress admin page since all the routes are redirected to index.html
.
I would like to redirect all routes to index.html
except this one, which links to my admin panel: www.mysite.com/wordpress/wp-login.php
This is my .htaccess
file
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
I tried this, but it didn't help:
...
RewriteCond %{REQUEST_URI} !^/wordpress
RewriteRule ^ index.html [QSA,L]
Upvotes: 3
Views: 285
Reputation: 2293
You can accomplish that with this code in your .htaccess (explanations in code):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# this line allows direct login to www.mysite.com/wordpress/wp-login.php
RewriteRule ^wordpress/wp-login\.php$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# everything else goes to www.mysite.com/index.html
RewriteRule . index.html [L,NC]
</IfModule>
# END WordPress
Upvotes: 1
Reputation: 9341
Your wordpress folder should have this htaccess code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^/wordpress/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
Upvotes: 1