没有index.php的路由不起作用 [英] Routes not working without index.php

查看:69
本文介绍了没有index.php的路由不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用laravel4.

Im using laravel 4.

我有一个视图nest.blade.php和相应的控制器NestController.php:

I have a view nest.blade.php and the corresponding controller NestController.php:

控制器内容:

class NestController extends BaseController {

    public function showView()
    {
        return View::make('nest');
    }

}

路线:

Route::get('/nest', 'NestController@showView');

当我转到url/nest时不起作用. 当我转到url/index.php/nest时,它确实起作用.

When I go to url/nest it doesnt work. When I go to url/index.php/nest it does work.

很显然,我只希望它是/nest而不包含index.php.

Obviously I just want it to be /nest without the index.php.

我该如何解决?

我的htaccess:

My 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>

推荐答案

漂亮的网址

该框架附带一个public/.htaccess文件,该文件用于允许 没有index.php的URL.如果您使用Apache服务Laravel 应用程序,请确保启用mod_rewrite模块.

The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.

如果Laravel随附的.htaccess文件不适用于您的 Apache安装,请尝试以下操作:

If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:

Options +FollowSymLinks
RewriteEngine On

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

有关更多帮助,请查看此答案.

For more related help, check this answer.

这篇关于没有index.php的路由不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆