I am working on an angular2 application which is placed along with wordpress site. Following is the directory structure:
/var/www/html
app/ (angular2 app is placed under this folder)
wp-includes/
wp-content/
...
htaccess file is placed under the html folder for wordpress url rewriting and another htaccess is placed under app folder for angular2 urls. I have updated htaccess file of wordpress to ignore urls under app folder but now urls of wordpress are not working and apache 404 is coming. Following is my htaccess file for wordpress:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} "/app/"
RewriteRule . index.php [L]
</IfModule>
RewriteCond %{REQUEST_URI} "/app/"
That directive doesn't "ignore urls under app folder" - it does the opposite and only routes the WordPress URLs when accessing a URL that contains /app/ (anywhere in the URL). To exclude that subdirectory, change the directive to:
RewriteCond %{REQUEST_URI} !^/app/
To match URLs that do not start with /app/ (note the ! prefix, that negates the regex).
However, if you already have a .htaccess file in the /app subdirectory that contains mod_rewrite directives then you shouldn't have to do this. The mod_rewrite directives in the subdirectory will completely override the mod_rewrite directives in the parent .htaccess file (since mod_rewrite directives are not inherited by default).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With