0

I have my laravel app inside www/mylaravelapp folder, and if I use / for home link, as in <a href="/">HOME</a>, for some reason it goes to localhost, not localhost/mylaravelapp.

Obviously it is not smart enough to do this on its own, so how do I tell it to?

Ollicca Mindstorm
  • 608
  • 1
  • 11
  • 24
  • Maybe this question is useful: https://stackoverflow.com/questions/16683046/how-to-install-laravel-4-to-a-web-host-subfolder-without-publicly-exposing-app – svrnm Nov 11 '15 at 17:06

3 Answers3

0

A good practise of Laravel is always to name the routes you define on routes.php

For example:

<?php
Route::get('/', array('as' => 'index', 'uses' => 'thisFunction@ThisController'));
Route::get('profile/{user}/edit', array('as' => 'user.edit', 'uses' => 'showEdit@UserController'));

And that way on your views, you can use:

<a href="{{ route('index') }}">HOME</a>
<a href="{{ route('user.edit', $user->id) }}">Edit profile</a>

And if one day you decide to change the URLs in the Routes, as long you don't rename them, you don't have to care about the links in the views, they will always be correct.

Th3Alchemist
  • 1,161
  • 2
  • 13
  • 25
0

Best practice in laravel is to generate paths thru path gererator. I had a problem with routing when added parameter to url. For example /main worked fine, but in case of /main/1 page styles crushed. Thats becouse src of includes have been changed from domain/folder on domain/public/folder. I know it do not hit subject directly, but folder structure and links do with helper methods to avoid that kind of problems

Janko
  • 202
  • 2
  • 11
-1

Best answer I found was on Laravel forum, basically if / is not working properly then use url() function which seems to work fine.

Ollicca Mindstorm
  • 608
  • 1
  • 11
  • 24