Edit: This is a major edit of my question, based on feedback in the comments, and a bit of reading on meta.stackoverflow.
I've shifted my goals, now my priority is to route top level URLs between Laravel and WP: I no longer seek to share code / databases / user creds, etc.
Question: What rewrite rules do I need to achieve a URL structure like this:
/ // (home) delivered by WP
/content1 // WP
/content(n) // WP
/dashboard // delivered by Laravel
/widgets/mywidget/ // Laravel
I've setup my files as follows, and have tested that each application works independently of one another. (Ie if Laravel's rewrite rules are the only ones in use, Laravel works fine using laravel-index.php)
From the web root: public_html/
/wordpress
/laravel3 // app dir
/css // these are from the laravel public dir
/images //
/js, etc //
/index.php // WP index.php
/laravel-index.php // laravel's index.php
I'm in a shared hosting environment with no access to httpd.conf.
Here is my .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^widgets - [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Laravel
<IfModule mod_rewrite.c>
RewriteRule !^widgets - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ laravel-index.php/$1 [L]
</IfModule>
In this way:
An additional problem is that WP Dashboard is stealing requests to /dashboard, which I'd like to redirect to Laravel
Thanks for reading!
For WordPress, you need to send all requests that are not in the widgets or dashboard folders to index.php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond !^widgets
RewriteCond !^dashboard
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
For Laravel, you need to do the opposite, send ONLY requests that are inside widgets or dashboard to laravel-index.php
# Laravel
<IfModule mod_rewrite.c>
RewriteCond ^widgets
RewriteCond ^dashboard
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ laravel-index.php/$1 [L]
</IfModule>
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