Reputation: 127
I have moved my index.php
for Laravel
from /public
to /public/api
. Right now, if I want to access it, I have to type the index.php
in the URL
as well.
For instance, to access a resource, I have to type localhost/api/index.php/resource
otherwise I get a 404 error
.
Can someone please help? The .htaccess
works fine on my friend's computer who is running a MAC, but it doesn't work on my Windows 8 computer:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /api/
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Upvotes: 0
Views: 70
Reputation: 4741
I highly recommend that you do not do this as I can see no reason that you should be altering where the index.php file is placed. You will likely run into other issues when making your application as well. With that said you need to modify the index.php file to contain the following lines. Notice the extra ../ since you have moved it up one directory.
require __DIR__ . '/../../bootstrap/autoload.php';
$app = require_once __DIR__ . '/../../bootstrap/start.php';
Also make sure the .htacess file is placed inside the same folder as your index.php file.
I should also note you should not have to modify the .htacess file at all for this. Remove the
RewriteBase /api/
line from your .htacess.
Upvotes: 1