1

I have just completed the Basic Task List laravel tutorial. But when i click on "Add task" button the url i get is http://localhost/task instead of http://localhost/laravel5.1/public/task which it should be. I have searched a bit but i could find an answear you to make the url pointing correctly. By the way i had forgoten to add the Application URL in the config/app.php. I added it, and creared cache with the php artisan cache:clear command but still nothing. My laravel version is 5.1 .

2
  • 1
    Laravel is designed for the 'web root' to be the public folder - everything else shouldn't be web accessible. Setting the 'application url' in config/app.php is only used when you are running an artisan command, etc. Commented Nov 24, 2015 at 18:52
  • Thanks. I set the public folder as root in my appache. Solved. Commented Nov 24, 2015 at 19:06

1 Answer 1

1

Reason : You should configure your application first and generate url properly

How : Inside config/app.phpset the 'url' => 'http://youraddresshost'

Note :

Changing the public folder as root in your apache is not the better solution, it won't work if you are moving the project to live server and you have multiple projects in it.

So, You should Generate your url in Laravel way i.e., via helper so that you can pointed to the correct destination.

Read more about Generating URL with laravel here

Even you can do this to generate the url as suggested here

echo url('user/profile');

echo url('user/profile', [1]);

Also, if you do some jquery function to redirect the url on button click, you should generate url accordingly.

Hope, this helps you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.