我的Hostmonster共享主机站点上的问题与主页之外的路由页面有关。我从这里使用Laravel框架的起始站点代码:
https://github.com/andrewelkins/Laravel-4-Bootstrap-Starter-Site
家庭工作正常,但除此之外我有问题。当我尝试登录时,当我的网址尝试访问http://example.com/user/login
时,我收到以下错误。如何解决此问题以便我的网页路由到正确的位置或如何解决此问题?谢谢。
错误:
Not Found
The requested URL /public/user/login was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at example.com Port 80
在我的.htaccess文件中我有
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
#AddType application/x-httpd-php54 .php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ public/index.php [L]
在我的路线中,我有这个
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
/** ------------------------------------------
* Route model binding
* ------------------------------------------
*/
Route::model('user', 'User');
Route::model('comment', 'Comment');
Route::model('post', 'Post');
Route::model('role', 'Role');
/** ------------------------------------------
* Route constraint patterns
* ------------------------------------------
*/
Route::pattern('comment', '[0-9]+');
Route::pattern('post', '[0-9]+');
Route::pattern('user', '[0-9]+');
Route::pattern('role', '[0-9]+');
Route::pattern('token', '[0-9a-z]+');
/** ------------------------------------------
* Admin Routes
* ------------------------------------------
*/
Route::group(array('prefix' => 'admin', 'before' => 'auth'), function()
{
# Comment Management
Route::get('comments/{comment}/edit', 'AdminCommentsController@getEdit');
Route::post('comments/{comment}/edit', 'AdminCommentsController@postEdit');
Route::get('comments/{comment}/delete', 'AdminCommentsController@getDelete');
Route::post('comments/{comment}/delete', 'AdminCommentsController@postDelete');
Route::controller('comments', 'AdminCommentsController');
# Blog Management
Route::get('blogs/{post}/show', 'AdminBlogsController@getShow');
Route::get('blogs/{post}/edit', 'AdminBlogsController@getEdit');
Route::post('blogs/{post}/edit', 'AdminBlogsController@postEdit');
Route::get('blogs/{post}/delete', 'AdminBlogsController@getDelete');
Route::post('blogs/{post}/delete', 'AdminBlogsController@postDelete');
Route::controller('blogs', 'AdminBlogsController');
# User Management
Route::get('users/{user}/show', 'AdminUsersController@getShow');
Route::get('users/{user}/edit', 'AdminUsersController@getEdit');
Route::post('users/{user}/edit', 'AdminUsersController@postEdit');
Route::get('users/{user}/delete', 'AdminUsersController@getDelete');
Route::post('users/{user}/delete', 'AdminUsersController@postDelete');
Route::controller('users', 'AdminUsersController');
# User Role Management
Route::get('roles/{role}/show', 'AdminRolesController@getShow');
Route::get('roles/{role}/edit', 'AdminRolesController@getEdit');
Route::post('roles/{role}/edit', 'AdminRolesController@postEdit');
Route::get('roles/{role}/delete', 'AdminRolesController@getDelete');
Route::post('roles/{role}/delete', 'AdminRolesController@postDelete');
Route::controller('roles', 'AdminRolesController');
# Admin Dashboard
Route::controller('/', 'AdminDashboardController');
});
/** ------------------------------------------
* Frontend Routes
* ------------------------------------------
*/
// User reset routes
Route::get('user/reset/{token}', 'UserController@getReset');
// User password reset
Route::post('user/reset/{token}', 'UserController@postReset');
//:: User Account Routes ::
Route::post('user/{user}/edit', 'UserController@postEdit');
//:: User Account Routes ::
Route::post('user/login', 'UserController@postLogin');
# User RESTful Routes (Login, Logout, Register, etc)
Route::controller('user', 'UserController');
//:: Application Routes ::
# Filter for detect language
Route::when('contact-us','detectLang');
# Contact Us Static Page
Route::get('contact-us', function()
{
// Return about us page
return View::make('site/contact-us');
});
# Posts - Second to last set, match slug
Route::get('{postSlug}', 'BlogController@getView');
Route::post('{postSlug}', 'BlogController@postView');
# Index Page - Last route, no matches
Route::get('/', array('before' => 'detectLang','uses' => 'BlogController@getIndex'));
答案 0 :(得分:2)
您是否在服务器配置中激活了URL重写?在 httpd.conf 文件中,您必须删除&#39; #&#39;在这2行的开头:
LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c
要确定它是否已激活,您可以检查 phpinfo()并查找 mod_rewrite 。