user4938195 user4938195 - 1 year ago 63
Linux Question

How to improve url in Laravel?

I created my app on Homestead. Everything works fine there. But when I moved app to an external server I always have to include index.php after root path.


How to I get rid of index.php to make my URL prettier?

Application is located:


Public directory is renamed to html:


PS. I'm using apache2.

Answer Source

Assuming you already point your web server to public directory, your problem should be in your Apache conf.

Laravel comes out with .htaccess in public/.htaccess but you need to enable the mod rewrite in Apache for it to work

sudo a2enmod rewrite

For the .htaccess to work, you need to set the AllowOveride directive in Apache conf

<Directory "/var/www/public">
AllowOverride All