简体   繁体   中英

HTML not rendering in Laravel Views

I'm new to Laravel and I'm trying to understand the correct way to handle web pages using Laravel.

Currently, I have a default route that leads to a file named login.php. login.php contains nothing but html, but when I go to localhost/myapp/public/index.php/ , login.php's html structure is displayed instead of the file rendering.

For example, if I were to say <\\p>Hello World<\\p> ( without the '\\', so a real paragraph tag ) , I would get <\\p>Hello World<\\p> instead of:

Hello World

My current route is this:

Route::get('/', function(){

    return View::make('login');

});

And login.php is just a basic html file. When the View gets returned, I get the html without the rendering.

This is my .htaccess file:

Options -MultiViews

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Any ideas? Oh, and sorry about the formatting for this question. I'm new to StackOverflow. Thanks!

the route file should look like this

Route::get('login', function() {
    return View::make('login');
});

assuming that login.php is in app/views/ folder.

and this is the url to access the login page assuming you are using artisan to run the server localhost:8000/login.php

My problem was that I had to start the Laravel Server in order to actually view my pages.

Once I did

php artisan serve

and went out to the root of my localhost, everything worked properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM