Your RewriteBase
is set to /myapp/
but your index.php file is in /mayapp/public/
is it not?
As such, I think you'll find the RewriteBase
needs to be /myapp/public/
.
Question
I have been spending hours on this issue and hope to find my way out. I have set up laravel correctly, created a project myapp
My route.php file just contains
Route::get('/', function()
{
return View::make('hello');
});
Route::get('/users', function()
{
return 'Users!';
});
When I run
http://localhost/myapp/public/
I get the laravel start page correctly
When I run
http://localhost/myapp/public/users
I get
The requested URL /myapp/index.php was not found on this server.
I don't know why its looking for index.php.
When I run
http://localhost/myapp/public/index.php/users
I get a page with text "Users". I should obtain this page when running
http://localhost/myapp/public/users
instead.
Below is my .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
Rewritebase /myapp/
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Any ideas? Am running a Apache on Linux.
No correct solution
OTHER TIPS
Your RewriteBase
is set to /myapp/
but your index.php file is in /mayapp/public/
is it not?
As such, I think you'll find the RewriteBase
needs to be /myapp/public/
.
Just do this and try to restart the apache.
sudo a2enmod rewrite
To restart apache: sudo services apache2 restart
I ran into same problem with production server, nothing seemed to work, no chmod/s no other solution but adding a simple line to .htaccess worked.
RewriteBase /
Thanks to the thread and user odaria
In your application/config/application.php file change:
'index' => 'index.php',
to:
'index' => '',
That should tell laravel not to use index.php and to rewrite correctly.
It works with standard .htaccess file which comes with laravel (haven't checked if you modified it)
Use this re-write rule:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /my_app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Also, in `application/config/app.php' change:
'index' => 'index.php'
to
'index' => ''
The quickest way is to add a symbolic link in command line:
ln -s your/acutal/path/myapp/public app-dev
Now browse http://localhost/app-dev
should work fine as well as all the routes. You can change app-dev to whatever you want as the name.