Laravel上的路由不断重定向(301)到网站的根目录 [英] Route on Laravel keeps redirecting (301) to root of website
问题描述
我有一个使用A2主机提供程序的应用程序,并且在公共目录中有我的laravel文件夹(www.website.com/app)
I have an application using the A2 host provider, and inside the public directory its my laravel folder (www.website.com/app)
在服务器首选项中,我将根目录"/"重定向到"/app"
And in my server preferences I am redirecting the root "/" to "/app"
该应用程序还可以,但是今天开始重新定向特定的路线.
The app was OK, but today started to redirect a Route in specific..
Route::get('/postagens/{Alias}/{dataInicio?}', array(
'as' => 'artista.get.posts.all',
'uses' => 'ArtistaController@getPostsMainFeed'
)
);
在生成的HTML中,它可以: http://www.website.com/app/artista/posts/twitter/一个> 但是当我访问此地址或通过jquery发送请求时,它会将我重定向到 http://www.website .com/artista/posts/twitter ,这给了我404(因为root内没有laravel应用...)
Inside the generated HTML, it makes: http://www.website.com/app/artista/posts/twitter/ but when I access this address or send request via jquery, it redirects me to http://www.website.com/artista/posts/twitter, and that gives me a 404 (because There's no laravel app inside root...)
所有其他路线仍在工作...
All the other Routes still working...
有什么想法吗?
谢谢
我在此处插入了错误的Route,但是顺便说一句,我通过不带第二个参数的路由来解决"此问题,并将其添加到javascript中,而不是使用laravel URL :: route.
I inserted the wrong Route here, but BTW, I "solved" this by making the route without the second parameter, and adding it on the javascript instead using laravel URL::route.
推荐答案
我在尝试到达提供的AuthController上的路由时遇到了同样的问题.原来是我没有看到的在构造函数中设置的中间件.
I was having the same problem trying to reach a route on the provided AuthController. It turned out to be middleware set in the constructor that I didn't see.
$this->middleware('guest', ['except' => 'logout']);
哪怕是注销路由,也有302个非访客到根页面,
Which was 302-ing non-guests to the root page, even for the logout route despite being an exception.
这篇关于Laravel上的路由不断重定向(301)到网站的根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!