Laravel 4路由无法正常工作,由于.htaccess文件?

编程入门 行业动态 更新时间:2024-10-17 21:23:42
本文介绍了Laravel 4路由无法正常工作,由于.htaccess文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在写我的步骤和结果在这里,所以你可以看到我已经试过,什么结果我得到了。任何建议将受到欢迎。我跟着这个答案。

I'm writing my steps and findings here so you can see what I've tried and what results I got. Any advice would be welcomed. I followed the comments in this answer.

我跑 Laravel 4 ,使用的 XAMMP版本1.8.2用PHP 5.4.19和Apache 2.4.4 Windows 7的机器上,我只是还在尝试启动和运行的本地实例。

I'm running Laravel 4, using XAMMP version 1.8.2 with PHP 5.4.19 and Apache 2.4.4 on a Windows 7 machine and I'm simply still trying to get a local instance up and running.

在我的情况:的http://本地主机/ SOS / sos_public / 是我的主屏幕,这样的作品,但是当我尝试去 HTTP://本地主机/ SOS / sos_public /注册我得到这个错误:的Symfony \分量\ HttpKernel \异常\ NotFoundHttpException 这已经讲过讲了很多上了网,然后我发现 GaryJ 说,它可能是一个的.htaccess 的问题,所以我做了什么,他建议说。

In my case: localhost/sos/sos_public/ is my main screen and that works, but when I try to get to localhost/sos/sos_public/signup I get this error: Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException which has been talked about a lot on the net, and then I found GaryJ stating that it might be an .htaccess issue, so I did what he suggested.

我的 /app/routes.php 文件看起来像这样(我已经试过这与 / 的对前注册太):

My /app/routes.php file looks like this (I've tried this with a / in front of signup too):

Route::get('signup', function() { return 'hello!'; }); Route::get('/', function() { return View::make('hello'); });

第一:

只是一会笑,看看 /index.php/hello 的作品。如果是这样,那么这是一个的.htaccess 的问题。

Just for a laugh, see if /index.php/hello works. If so, then it's a .htaccess problem.

的http://localhost/sos/sos_public/index.php/signup 完全正常工作。所以这是一个的.htaccess 的问题。

localhost/sos/sos_public/index.php/signup worked perfectly fine. So it's an .htaccess problem.

我的的.htaccess 文件是这样的:

<IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>

如果你正在运行的的Apache 2.4 ,注意因为previous的变化   版本,关于要求所有批准和的AllowOverride所有中的   &LT;目录/&GT; ...&LT; /目录&GT; 您的虚拟主机上块

if you're running Apache 2.4, note the changes since previous versions, regarding Require all granted and AllowOverride all within a <Directory />...</Directory> block on your virtual host.

我说这在我的 httpd.conf文件所建议的道尔顿·戈尔 - 得到了的Symfony \分量\ HttpKernel \异常\ NotFoundHttpException 错误(改变了这一目录路径 / SOS / sos_public 和 C:/ xammp / htdocs中/ SOS / sos_public / 和 C:/ xammp / htdocs中/ SOS / sos_public - 同样的结果):

I added this in my httpd.conf file as suggested by Dalton Gore - got the Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException error (changed this directory path to /SOS/sos_public and C:/xammp/htdocs/SOS/sos_public/ and C:/xammp/htdocs/SOS/sos_public - same results):

<Directory /> AllowOverride none Require all denied </Directory> <Directory /SOS/sos_public> AllowOverride all Require all granted </Directory>

下一步:

检查的.htaccess 什么是工作

我添加 dsjkdsfghk 我的的.htaccess 文件,并立即得到一个错误,所以我知道我的的.htaccess 文件正在被使用。

I added dsjkdsfghk to my .htaccess file and immediately got an error, so I know my .htaccess file is being used.

然后:

尝试删除 IfModule 的条件。当你有访问   主机/虚拟主机,你很快就可以启用模块,如果它不是 - 所以它   不需要在每次请求进行检查。同样,尝试移动它   对的.htaccess ,并进入&LT;目录/&GT; ...&LT; /目录&gt;在块的   虚拟主机 - 如果你有没有别的你的.htaccess就可以将其   删除。

Try removing the IfModule conditional. As you've got access to the host / vhost, you can soon enable that module if it's not - so it doesn't need be checked on every request. Equally, try moving it out of .htaccess, and into a <Directory />...</Directory> block in your vhost - if you've got nothing else in your .htaccess it can then be deleted as well.

  • 有一个空的的.htaccess 文件引起了 404 在我的浏览器错误 HTTP ://本地主机/ SOS / sos_public /注册(的http://本地主机/ SOS / sos_public / 仍然工作)。
  • 从删除的.htaccess 文件C:\ XAMPP \ htdocs中\ SOS \ sos_public \ 有同样的结果

  • Having an empty .htaccess file caused a 404 error in my browser for localhost/sos/sos_public/signup (localhost/sos/sos_public/ still worked).
  • Removing the .htaccess file from C:\xampp\htdocs\SOS\sos_public\ had the same results.
  • 然后:

    尝试:&LT;虚拟主机*:80&GT;的DocumentRoot   /用户/ amiterandole /网站/ laravelbackbone /公众服务器名   laravelbackbone.dev&LT;目录/&GT;所有的AllowOverride要求所有   给予&LT; /目录&GT; &LT; IfModule mod_rewrite.c&GT;选项​​-MultiViews   RewriteEngine叙述上的RewriteCond%{} REQUEST_FILENAME!-f重写规则^   的index.php [1]; / IfModule&GT; &LT; /虚拟主机&GT;

    Try: <VirtualHost *:80> DocumentRoot "/Users/amiterandole/Sites/laravelbackbone/public" ServerName laravelbackbone.dev <Directory /> AllowOverride all Require all granted </Directory> <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </VirtualHost>

    我没有这一点,就像阿密特,

    I did that and just like Amit,

    我掏空了我的的htaccess 文件,并尝试了上面,现在什么   似乎工作。

    I emptied out my htaccess file and tried the above and now nothing seems to work.

    除非他的 laravelbackbone.dev 指着自己的网​​站文件夹的根,我只是得到了一个错误400 - 错误请求在两个的http://本地主机/ SOS / sos_public / 和的http://本地主机/ SOS / sos_public /注册当我跑他们在我的浏览器。

    Except where his laravelbackbone.dev pointed to his Sites folder root, I just got an Error 400 - Bad request on both localhost/sos/sos_public/ and localhost/sos/sos_public/signup when I ran them in my browser.

    我的的httpd-vhosts.conf 文件是这样的:

    <VirtualHost *:80> DocumentRoot "C:/xammp/htdocs/SOS/sos_public" ServerName sos.dev <Directory /> AllowOverride all Require all granted </Directory> <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </VirtualHost>

    和我.hosts文件我明明有:

    and in my .hosts file I obviously had:

    127.0.0.1 sos.dev

    最后:

    您已经肯定了的的conf /加/的httpd-vhosts.conf 文件是   包括(取消注释)中的主的httpd.conf ?

    You've definitely got the conf/extra/httpd-vhosts.conf file be included (uncommented) within the main httpd.conf?

    我有这个取消注释 - 对

    I have this uncommented - yes.

    另一个链接我试过,但无济于事: stackoverflow/a/17778222/956975 并的www.epigroove/blog/laravel-routes-not-working-make-sure-htaccess-is-working

    Another link I tried but to no avail: stackoverflow/a/17778222/956975 and www.epigroove/blog/laravel-routes-not-working-make-sure-htaccess-is-working

    我应该改变在哪里? 我在想什么?

    What should I change where? What am I missing?

    推荐答案

    您ServerName是

    Your ServerName is

    sos.dev

    和阿帕奇借此考虑,你必须使用你的访问路线:

    And apache take this in consideration, you you must access your routes using:

    sos.dev/

    而不是

    localhost/

更多推荐

Laravel 4路由无法正常工作,由于.htaccess文件?

本文发布于:2023-10-31 13:22:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   无法正常   文件   工作   Laravel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!