Reputation: 255
I'm a beginner in Laravel
I have just installed Laravel to my local server using xampp in E drive instead of c. When i opened this url http://localhost/laravel/public/ its working fine. I have created hello controller but when trying to open this url: http://localhost/laravel/public/hello getting page not found error.
I tried all htacess methods but still not working. Please help me to access controller.
Upvotes: 2
Views: 2132
Reputation: 6625
Since you are using XAMPP, it will be better for you to register a new virtual host on your xampp's Apache. Just go to /path-to-xampp/apache/conf/extra/httpd-vhosts.conf
And add this code
<VirtualHost *:80>
ServerName mylaravel-app.local
DocumentRoot "e:/path-to-xampp/htdocs/laravel/public"
<Directory "e:/path-to-xampp/htdocs/laravel/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
After that, you save it and restart your XAMPP to refresh its DNS. Then you can now view your app on http://mylaravel-app.local
UPDATE for sample code:
// app\Http\Controllers\Hello.php
class Hello extends Controller {
public function index() {
echo "Hello world!";
}
...
}
// routes:
Route::get('/hello', 'Hello@index');
// then you test it on http://mylaravel-app.local/hello
Upvotes: 3
Reputation: 256
You also need to start your laravel server. First go to your project root directory from CMD. Than run Command php artisan serve in cmd. so the laravel server is started. After this you not get error of page not found !
Upvotes: 0