我是基于php的web开发的noob,我正在尝试从头开始的Laravel教程。
首先,我使用不会强制https的.dev
在laragon偏好设置中修复了.mc
的问题。
欢迎信息页
的链接为http://localhost/e-commerce-tutorial/public/现在我正在尝试创建路由方案
我确实在about.blade.php
resources/views/pages
页面
然后我编辑了laravel wellcome页面,将此链接添加到菜单中:
<a href="{{ url('/about') }}">About</a>
最后我的web.php
Route::get('/', function () {
return view('welcome');
});
Route::any(
'/about',
function (){
return view('pages.about');
}
);
我做了一些研究,但没有成功:
我试过这两个.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
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]
</IfModule>
OR
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我的浏览器回复是:
未找到请求的URL /电子商务教程/ public / about不是
在此服务器上找到。
答案 0 :(得分:1)
试试这个 .htaccess文件
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#RewriteBase /~projectname/master/
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
另请尝试这个
Route::get('/about', function () {
return view('pages.about');
});
Route::post('/about', function () {
return view('pages.about');
});