Hamza Moslah
Hamza Moslah

Reputation: 74

Change Laravel base URL from localhost to localhost/laravel5

I'm trying to change Laravel base URL to localhost/laravel5, I tried to change APP_URL variable in .env file, I did the same changes to this line in config/app.php file:

'url' => env('APP_URL', 'http://localhost/laravel5')  

And here my /etc/apache2/sites-available/laravel.conf file:

    <VirtualHost *:80>
    ServerName localhost/laravel5

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/laravel5/public

    <Directory /var/www/html/laravel5>
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I also tried to restart apache2 service, but nothing changes

Upvotes: 0

Views: 1935

Answers (2)

lewis4u
lewis4u

Reputation: 15047

Make your virtual server like this in apache

<VirtualHost *:80>
        ServerName laravel5.app
        DocumentRoot /var/www/html/laravel5/public

        <Directory /var/www/html/laravel5/public>
            AllowOverride All
            Require all granted
        </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

and run

sudo a2ensite laravel5.app
service apache2 reload

Finally, make sure to edit your /etc/hosts file and add an entry for laravel5.app:

# other entries...

# your entry...
127.0.0.1    laravel5.app

And then you can access your app at http://laravel5.app

Upvotes: 0

Jeff
Jeff

Reputation: 166

I recommend You to use something like Homestead or Valet for developing Check the docs here

Upvotes: -1

Related Questions