dongpan1308 2015-01-08 07:49
浏览 148

如何使用给定的URL访问控制器方法

I am using laravel framework. I need to access controller method with the name of the given url. My routes code look like below :

   <?php
      Route::get('home','HomeController@showWelcome');
   ?>

HomeController.php look like this

   <?php

     class HomeController extends BaseController {
        public function showWelcome()
       {
          return View::make('hello');
       }
     }

   ?>

My problem is can't able to access the method of showWelcome while giving the url like http://example.com/home

But i can able to access with the url http://example.com/index.php/home

How to sove this issue.. can anyone help me to do this..Thanks in advance.

.htaccess file look like below :

 <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>
  • 写回答

2条回答 默认 最新

  • duanji7881 2015-01-08 08:05
    关注

    This should be a comment,but I don't have enough reputation now.

    This is a rewrite problem,have a look at http://laravel.com/docs/4.2/installation#pretty-urls to check out you have right configuration.

    If you are using apache and your .htaccess doesn't work,it's because the mod_rewrite is turned off.

    Hope this helps.

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?