【发布时间】:2020-09-01 17:09:09
【问题描述】:
您好,我是 laravel 初学者,在页面导航时遇到问题。
http://localhost/mylaravel/public/index
在索引页面中,我有几个项目,在 href 下方可以根据项目 ID 查看该项目的详细信息。*
<a href="{{route('singleitem',$product->id}}">
Route::get('/single/{id}', 'ProductController@single')->name('singleitem');
Route::get('/index', 'ProductController@index');
现在当我点击商品详情时,我会得到以下 URL,这没问题。
http://localhost/mylaravel/public/single/25T8C (here id = 25T8C)
现在,当我单击主页时,它会从该页面添加单个 [single/index !!!] 的索引页面结尾
<a href="index" class="nav-link">Home</a>
http://localhost/laravel-test/mylaravel/public/single/index
我尝试添加斜线,但它被重定向到
<a href="/index" class="nav-link">Home</a>
http://localhost/index
这是我的 .htaccess
<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>
任何帮助将不胜感激。
【问题讨论】:
-
你在用xammp/lamp吗???
-
我正在使用 xammp
-
是的,按照我的回答去做。如果答案有效,请标记为确认任何其他问题请评论
标签: php laravel .htaccess xampp