0

I have uploaded my laravel 4.2 application to a /subfolder of a shared hosting like www.example.com/bangla by following this answer.

Structure of my application is

example.com/    (the root of your web hosting)
|-- laravel4_base/   (Here goes all contents except public folder)
|-- [some other folders...]
|-- public_html/    
|   |-- [some other folders...]
|   |-- bangla/      (Here goes contents of public folder)

Now i have these menu link in my view

<li><a href="/">Home</a></li>
<li><a href="/rj">Rj</a></li>

My problem is whenever i click them should route me to

www.example.com/bangla
www.example.com/bangla/rj

But it takes to

www.example.com
www.example.com/rj

My route.php looks like

Route::get('/','HomeController@index');
Route::get('rj','HomeController@rj');

HomeController.php looks like

public function index()
{
    return View::make('home');
}
public function rj()
{
    return View::make('rj');
}

So basically the base path is not being changed to subfolder www.example.com/bangla

I did a lot of searching in stackoverflow. Some are

laravel 4 setting base url to /subfolder

How to set sub-directory for base URL of laravel?

Also in laracast. But all are either unanswered or they do not have any answer that resolves the problem.

So, in simple words the question is how to change base url from www.example.com to www.example.com/bangla

Community
  • 1
  • 1
Zahan Safallwa
  • 3,880
  • 2
  • 25
  • 32

2 Answers2

1

If you use a URL that starts with / it will tell the browser that it is an absolute URL so the browser will natually start looking for it from root of your current URL, which is always the domain.

To prevent this, you can use laravel's helper functions to generate the URL for you.

http://laravel.com/docs/4.2/helpers#urls

<li><a href="{{ action('HomeController@index') }}">Home</a></li>
<li><a href="{{ action('HomeController@rj') }}">Rj</a></li>
Malitta N
  • 3,384
  • 22
  • 30
0

I met this problem too and m'm code like this

<a class='btn btn-warning' href='{{ url('/jobCatEdit/'.$dtJobCat->jcid) }}'>

and it's work