Mic*_*ijs 0 wampserver laravel laravel-routing laravel-5
我对Laravel相当陌生,我曾与Laravel 4一起工作过,但决定将新的Laravel 5花哨的个人项目用于个人项目并真正学习它。
我本想将其发布在Webmasters.SE上,但是找不到关于Laravel的其他任何问题。
我在互联网上找不到任何解决方案,我很乐意提供更多信息。
因此,我只是在本地WAMP服务器上使用他们自己的安装方法安装了一个新的Laravel 5应用程序。我做了整个Composer mumbo-jumbo,一切都完成了,没有出现错误。
问题
现在,这是我的问题,当我使用http://localhost/test.com/public/
默认值页面访问网站时,应该会得到默认页面。
在routes.php
(如下所示)中,您将看到他们定义了home
一条路线。因此,我在网址栏中输入了它,http://localhost/test.com/public/home
然后重定向回了http://localhost/test.com/public/auth/login
,如下图所示。
(它没有任何样式,我假设它应该像这样吗?)
无论如何,我到达那里,然后将鼠标悬停在Home
左下方/右下方的小网址栏上,http://localhost
然后单击它将我重定向到WAMP Server主页。
这些是它们链接到的URL:
http://localhost
http://localhost/auth/login
http://localhost/auth/register
http://localhost/password/email
所需的结果应该是应该将我重定向到 http://localhost/test.com/..
我不知道在哪里,这可能已经造成,我asuming这一点是必须有.htaccess
,routes.php
或者paths
没有正确设置。我曾尝试修改两者.htaccess
,routes.php
但我显然不具备自己调试此问题的知识。
代码资源(全新安装,未做任何更改)
routes.php
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'WelcomeController@index');
Route::get('home', 'HomeController@index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
Run Code Online (Sandbox Code Playgroud)
.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>
Run Code Online (Sandbox Code Playgroud)
您需要在中配置url
参数config/app.php
(或您相应的环境配置文件)。默认情况下,此设置为http://localhost
,因此您需要将其设置为http://localhost/test.com/public/
。
编辑
看起来视图中的url是经过硬编码的(例如)。解决方法是与此相同的答案,这是每一个取代硬编码的网址(如<li><a href="/">Home</a></li>
用)url()
帮助(例如<li><a href="{{ url('/') }}">Home</a></li>
)。
归档时间: |
|
查看次数: |
4406 次 |
最近记录: |