【发布时间】:2015-03-27 14:43:30
【问题描述】:
我刚开始学习 laravel,我正在使用 MAMP。我在这个网址有一个表单:http://localhost:8888/laravel-site/my-new-app/public/ducks,但是当我提交表单时,它会将我带到这个网址:http://localhost:8888/ducks,并且不会停留在我期望的位置。
routes.php 文件包含以下内容:
Route::get('ducks', function()
{
return View::make('duck-form');
});
// route to process the ducks form
Route::post('ducks', function()
{
// process the form here
});
在我的 .htaccess 文件中,我有这个:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /laravel-site/my-new-app/public/
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我可能遗漏了一些非常明显的东西,但是为什么当我提交表单时它没有留在同一页面上?
【问题讨论】:
-
添加处理表单的代码。
-
我现在只有返回“表单已发布!”; @Amr
-
把这个返回 Redirect::back();而是尝试一下。
-
不,只要我点击提交,我就会被带到这里:localhost:8888/ducks@Amr
-
@Amr 我应该这样做吗? epigroove.com/blog/…
标签: php .htaccess laravel laravel-4