doumalu9257 2015-12-19 17:45
浏览 77
已采纳

无法在Laravel框架中路由

I create an app with Laravel framework in PHP.

I have a problem with routing.

.htaccess file looks like this:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# 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]

routes.php:

<?php
get('/', function () {
return view('welcome');
});


get('1', function() { return 'Je suis la page 1 !'; });
get('2', function() { return 'Je suis la page 2 !'; });

When I load http://localhost:63342/game/public/, server loads welcome.blade.php file, so it's okey. But when I want to load http://localhost:63342/game/public/1, I got error: 404 Not Found. I use appache server and I already enabled 'mod_rewrite' action. What can be problem?

  • 写回答

2条回答 默认 最新

  • douxian9010 2015-12-20 10:25
    关注

    I found solution. I enabled mod_rewrite action for apache server in httpd.conf, but problem was, that I didn't set correct directory path in this file for my projects.

    It should have looked like this:

    DocumentRoot "/Applications/MAMP/htdocs"
    
    <Directory "/Applications/MAMP/htdocs" >
        Options Indexes FollowSymLinks
        AllowOverride All 
    </Directory>
    

    Hope, it helps someone in future.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据