user4938195 user4938195 - 2 years ago 112
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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download