我的问题与this another question非常相似,但该帖子中提供的解决方案对我没有帮助。
我使用此guide将我的Laravel应用部署到共享托管服务(BTW,该指南与链接问题的one of the answers非常相似)
以下是我的routes / web.php文件
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::group(['prefix' => 'law', 'middleware' => ['ability:superadministrator,read-users|create-users']], function () {
Route::get('/search', 'LawController@showSearchView');
Route::get('/new', ['middleware' => ['permission:create-users'], 'uses' => 'LawController@showNewView']);
Route::get('/find', 'LawController@find');
Route::get('/edit/{id}', 'LawController@edit');
//region post
Route::post('/new', ['middleware' => ['permission:create-users'], 'uses' => 'LawController@store']);
Route::post('/search', ['middleware' => ['permission:read-users'], 'uses' => 'LawController@search']);
/*Route::post('/modify', ['middleware' => ['permission:create-users'], 'uses' => 'LawController@modify']);*/
//endregion
});
Route::group(['prefix' => 'user', 'middleware' => ['ability:superadministrator,read-users|create-users']], function () {
//..similar to the previous one
});
//some other route groups
问题是,我可以访问欢迎页面和登录页面。验证后,我转到主页,然后问题开始。除了我尝试之外的所有其他路线(如mydomain.net/law/search)在某种无限循环中再次离开我的主页。注销路线也可以正常工作。
如果我尝试像mydomain.net/blah这样的不存在的路线,那么我觉得很有意思。我会去知识RouteNotFound /&#34; NotFoundHttpException&#34; Laravel框架。
我在php日志或浏览器控制台中没有收到任何错误。 javascript工作正常。
我联系主机服务的支持,以确保Apache启用了mod_rewrite,显然是。
我用谷歌搜索了大约3个小时,然后在这里深入挖掘,但是任何事情都帮助我理解了这个问题。有提示吗?
以下是.htacces文件,如果它有任何帮助:
<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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
MISC:
答案 0 :(得分:0)
在.htaccess文件中添加此内容
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
此规则将在内部将REQUEST_URI的内容加载到index.php