简体   繁体   English

Laravel - 404 找不到除主页之外的所有页面

[英]Laravel - 404 Not found every page except homepage

I'm newbie on Laravel.我是 Laravel 的新手。 I'm using Laravel 5 - Wamp on Windows 8. Every page on my localhost have 404 not found error except homepage.我在 Windows 8 上使用 Laravel 5 - Wamp。除了主页之外,本地主机上的每个页面都有 404 not found 错误。 Although I can access them with index.php .虽然我可以使用 index.php 访问它们。 For example URL is :例如网址是:

http://localhost/mpr/public/index.php/register http://localhost/mpr/public/index.php/register

is okay.没关系。 Actually实际上

http://localhost/mpr/public/register http://localhost/mpr/public/register

has an error (404 not found).有错误(404 未找到)。

I've checked rewrite_module but it was not changed.我检查了 rewrite_module 但它没有改变。 Any suggestion?有什么建议吗?

On command prompt, go to your laravel folder,在命令提示符下,转到您的 Laravel 文件夹,

cd C:/wamp/www/laravel-app-folder

and run并运行

php artisan serve. 

Now try to access your app on localhost:8000现在尝试在localhost:8000上访问您的应用程序

Now, you will be able to access your routes like localhost:8000/register现在,您将能够访问您的路由,例如localhost:8000/register

It is rewrite mode issue.这是重写模式问题。

Go to wamp/bin/apache/apache2423/conf/httpd.conf and remove hash<#> from LoadModule rewrite_module modules/mod_rewrite.so this line.转到wamp/bin/apache/apache2423/conf/httpd.conf并从LoadModule rewrite_module modules/mod_rewrite.so这一行中删除hash<#>

Now you can access all pages.现在您可以访问所有页面。

Go in .htaccess file and add this line进入 .htaccess 文件并添加这一行

RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]

And if not present .htaccess file in public folder then you have to upload .htaccess file and add this line of the code after then you will find the remove error如果公共文件夹中没有 .htaccess 文件,那么你必须上传 .htaccess 文件并添加这行代码,然后你会发现删除错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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