@vadimstroganov

Почему не работает роутинг в Laravel?

Добрый день!
Никак не могу справиться с роутингом в Laravel.
В App/View лежат два файла index_ru.php и index_en.php

Прописываю в routes.php следующее:
Route::get('/', 'MainController@index_ru');
Route::get('/en', 'MainController@index_en');

MainController:
public function index_ru()
	{
		return View::make('index_ru');
	}

	public function index_en()
	{
		return View::make('index_en');
	}


.htaccess в корне:
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

DirectoryIndex public/index.php


.htaccess в /public :
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>


Первый роут отображает что нужно, а если так сайт/en, то не работает:
Not Found
The requested URL /index.php was not found on this server.
Apache/2.2.22 (Debian) Server at сайт Port 80

Что я не так делаю?
  • Вопрос задан
  • 4915 просмотров
Решения вопроса 1
@vadimstroganov Автор вопроса
Изменил .htaccess в корне на:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Теперь все работает.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
Route::get('/en', 'MainController@index_en');
// Должно быть так
Route::get('en', 'MainController@index_en');
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы