Abel Raj Abel Raj - 6 months ago 29
PHP Question

Deploy Laravel and Angular local with apache

I am using Laravel and angular. My app works with artisan serve command on localhost:8000

If i want to deploy locally without using artisan command I copied to var/www/html/ and run localhost/project/public it works.

My landing page is login and it routes with

localhost/project/

But I click the link on the landing page i get 404 not found with url
localhost/project/login
.

I found a way with
localhost/project/index.php/login
. this works but my angular ng-view is blank.

How to make laravel with angular work without php artisan serve?

Answer

You're going to want to use something like a .htaccess rule to tell Apache to strip out index.php from the URL.

I've used the following on previous projects:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

EllisLab (creators of CodeIgniter framework) also have a good guide on this: https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html

Comments