Chamara Maduranga
Chamara Maduranga

Reputation: 256

How to add Laravel route

Crated laravel project using below command

composer create-project --prefer-dist laravel/laravel blog

successfully created blog project "http://localhost/blog/public/" after that added below code in "routes.php" file

Route::get('about', function () {
    return view('welcome');
});

but after that when i type "http://localhost/blog/public/about" its displaying 404 page.

if anyone have any idea please share with me

Upvotes: 0

Views: 1284

Answers (3)

Try to put .htaccess file to Your laravel home directory. It seems, You need .htaccess with next content:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(.*)$ blog/public/$1 [L]
</IfModule> 

Surely, your apache mod_rewrite have to be enabled.

Upvotes: 2

Tzook Bar Noy
Tzook Bar Noy

Reputation: 11677

Well I don't know how you serve the application, apache, nginx or php simple serving.

Lets start from here:

  1. List item
  2. open terminal
  3. go to project folder (where the "artisan" file is located)
  4. run: "php artisan serve"
  5. open in the browser -> "http://localhost:8000"
  6. you suppose to see laravel welcome page
  7. now go to -> "http://localhost:8000/about"
  8. now again you suppose to see laravel welcome page

Upvotes: 3

Jenis Patel
Jenis Patel

Reputation: 1615

It seems like you are missing about.blade.php view for your about action.

Also check that are you getting control inside about route using below code snippet.

Route::get('about', function () {
    $testVar = "Demo data";
    return $testVar;
});

Upvotes: 0

Related Questions