How to set base url to /subfolder in Laravel 4.2

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

Structure of my application is    (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="/" rel="nofollow noreferrer noopener">Home</a></li>
<li><a href="/rj" rel="nofollow noreferrer noopener">Rj</a></li>

My problem is whenever i click them should route me to

But it takes to

My route.php looks like
Route::get('/','<a href="" class="__cf_email__" data-cfemail="c28aadafa781adacb6b0adaeaea7b082abaca6a7ba">[email protected]</a>');
Route::get('rj','<a href="" class="__cf_email__" data-cfemail="420a2d2f27012d2c36302d2e2e2730023028">[email protected]</a>');

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

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 to


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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.

<li><a href="{{ action('<a href="" class="__cf_email__" data-cfemail="97dff8faf2d4f8f9e3e5f8fbfbf2e5d7fef9f3f2ef">[email protected]</a>') }}" rel="nofollow noreferrer noopener">Home</a></li>
<li><a href="{{ action('<a href="" class="__cf_email__" data-cfemail="b2fadddfd7f1dddcc6c0dddeded7c0f2c0d8">[email protected]</a>') }}" rel="nofollow noreferrer noopener">Rj</a></li>

Method 2

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

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x