I’m trying to get wordpress and laravel to run side-by-side and hitting a small issue.
Here’s my code
# BEGIN Laravel
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?admin/?.*$ index.php [L]
</IfModule>
# END Laravel
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp-index.php [L]
</IfModule>
# END WordPress
the wordpress pages work, apart from the homepage and the admin pages work (laravel), apart from if there is no ‘/’ at the end.
Any ideas?
regards
There’s something wrong with routing. This question may solve your issue:
PHP Laravel Routing Issue
Try all of the suggestions, especially the ones concerning apache config.
‘Rewrite’ means “treat the URL as if it matches this filename”. The file run can still tell what the original URL was, so it knows what to show.
The code
means that if the file with the specified name doesn’t exist, or the directory in the browser doesn’t exist then proceed to the rewrite rule below.
The first rule you have is ‘send anything that has /admin/ in it to index.php’ – presumably Laravel.
The second rule you have is ‘send anything to wp-index.php’ – presumably WordPress.
Servers are typically set up to direct / to index.php, and the line
means “don’t rewrite index.php, and stop”, so that’s why the “home page” is going to Laravel.
Comment that line out (add a # to the beginning) and see if that makes your home page go to WordPress.
Also, /admin won’t direct to Laravel because it doesn’t match the rule (which is based on /admin/). If you want /admin to work, take out the / from the first rule.