I’m working with a website built on WordPress, it’s a fairly standard setup in cPanel. I’ve developed new features for the website in Laravel. I now need to view the Laravel public directory to an accessible web address.
I’ve tried symlinking the public Laravel directory to a directory inside public_html (where WordPress is).
I’m getting a WP 404 error, rather than the symlinked folder (Laravel public).
/home/user/public_html/ (WordPress DIR)
/home/user/repositories/laravel-app/public (Laravel public)
I then ran:
ln -s /home/user/repositories/laravel-app/public/ /home/user/public_html/book-online
I was hopeful that when going to domain.com/book-online
it would load the Laravel app but it doesn’t appear to be the case.
Update
I’ve managed to move a little further, I’ve realised the directory is definitely being resolved, I can access assets, just not index.php. For example. I can go to URL:
domain.com/book-online/css/style.css
and it will load the Laravel stylesheet
domain.com/book-online/index.php
gives me WordPress 404.
This is my .htaccess in public Laravel folder.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]
</IfModule>
2
Answers
Setting proper permissions fixed the issue.
I needed to set permissions on the public folder to 755 and also the index.php file to 644.
For others who may land here with a similar problem: First, you must symlink the public folder (or rename the public folder and move it to a publically accessible location) and set the permissions as above.
It looks like you’re missing the /repositories folder in the symlink path “ln -s /home/user/laravel-app/public/”
Also make sure your DNS entry is set up to look for the url you need : domain.com/book-online in your cpanel