My laravel installation was working fine yesterday but today I get the following error:
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Does anyone know where I am going wrong?
asked Aug 16, 2013 at 11:44
2
Create and put this .htaccess file in your laravel installation(root) folder.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
answered Apr 20, 2015 at 13:12
AlexeyAlexey
7,1479 gold badges57 silver badges94 bronze badges
4
For me, It was just because I had a folder in my public_html named as same as that route!
so please check if you don’t have a folder with the address of that route!
hope be helpful
answered Sep 3, 2018 at 4:16
AliAli
1,5251 gold badge16 silver badges27 bronze badges
5
I met the same issue, then I do same as the solution of @lubat and my project work well.
My virtualhost configuration:
<VirtualHost *:80>
ServerName laravelht.vn
DocumentRoot D:/Lavarel/HTPortal/public
SetEnv APPLICATION_ENV "development"
<Directory D:/Lavarel/HTPortal/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
answered Oct 8, 2015 at 8:06
0
Check your virtual host configuration.
For Ubuntu you could find it at /etc/apache2/sites-available/yourlaravel.conf
It should be like this:
<VirtualHost *:80>
ServerName yourlaravel.com
DocumentRoot "/path/to/your/laravel/project/public"
ServerAlias *.yourlaravel.com
<Directory "/path/to/your/laravel/project/public">
AllowOverride All
Require all granted
</Directory>
The key line is Require all granted
inside <Directory>
.
Hope it helps!
answered Jul 30, 2015 at 10:21
lubartlubart
1,7463 gold badges27 silver badges35 bronze badges
Just add a .htaccess
file in your root project path with the following code to redirect to the public folder:
.HTACCESS
## Redirect to public folder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
Very simple but work for me in my server.
Regards!
answered Apr 3, 2018 at 17:57
3
Have you tried to change the .htaccess file that laravel suggested if the default one doesn’t work? I had this similar problem and changed it to
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
and it soleved
answered Aug 17, 2013 at 7:34
2
It was solved for me with the Laravel default public/.htaccess file adding an extra line:
The /public/.htaccess
file remains as follows:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
DirectoryIndex index.php # <--- This line
# 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>
answered Jul 20, 2016 at 20:41
EvhzEvhz
8,8519 gold badges51 silver badges69 bronze badges
0
For those who using Mamp or Mamp pro:
Open MAMP Pro
Click on “Hosts”
Click on “Extended” (UPDATE: Only if you are using MAMP Pro 3.0.6)
Check “Indexes”
Click “Save”
That’s it! Reload your localhost starting page and it should work properly.
answered Dec 28, 2014 at 12:30
DixitDixit
12.7k3 gold badges49 silver badges46 bronze badges
0
With me the problem appeared to be about the fact that there was no index.php file in the public_html folder. When I typed in this address however: http://azxcvfj.org/public , it worked (this address is just an example. It points to nowhere). This made me think and eventually I solved it by doing the following.
I made a .htaccess file in the app’s root folder (the public_html folder) with this contents:
<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 ^ public/index.php [L]
</IfModule>
And this worked. With this file you are basically saying to the server (Apache) that whenever someone is trying to access the public html folder(http://azxcvfj.org) that someone who is being redirected is redirected to http://azxcvfj.org/public/index.php
answered Nov 9, 2014 at 17:26
PieterVKPieterVK
1,4811 gold badge10 silver badges4 bronze badges
First, update your Virtual Host configuration;
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/example-project/public
<Directory /var/www/html/example-project/public/>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Then, change both permission and ownership of the asset as illustrated below.
$ sudo chgrp -R www-data /var/www/html/example-project
$ sudo chmod -R 775 /var/www/html/example-project
nyedidikeke
6,9378 gold badges44 silver badges59 bronze badges
answered Aug 20, 2017 at 16:56
YvesYves
80715 silver badges17 bronze badges
In your VirtualHost write the DocumentRoot to point to your Laravel Application in your home directories. In addition you must add the Directory shown below, with your own path:
<Directory /home/john/Laravel_Projects/links/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
The second step, you must go to your Laravel Project and run the following command.
sudo chmod -R 777 storage bootstrap/cache
At the end restart your apache2:
sudo service apache2 restart
answered Dec 5, 2018 at 4:31
2
This is solved my problem by adding this line:
DirectoryIndex index.php
Grant Miller
27.6k16 gold badges147 silver badges165 bronze badges
answered Jun 3, 2018 at 0:18
In my case, this error was due to internal links in the server, PHP wasn’t able to access those folders unless the proper option for that was added to .htaccess
.
Add the following line after RewriteEngine On
:
Options +FollowSymLinks
answered Nov 19, 2019 at 17:53
António AlmeidaAntónio Almeida
9,6408 gold badges59 silver badges66 bronze badges
1
Chances are that, if all the answers above didn’t work for you, and you are using a request validation, you forgot to put the authorization to true.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class EquipmentRequest extends FormRequest {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
/*******************************************************/
return true; /************ THIS VALUE NEEDS TO BE TRUE */
/*******************************************************/
}
/* ... */
}
answered Jun 4, 2018 at 14:15
Amin NAIRIAmin NAIRI
2,30221 silver badges20 bronze badges
1
If you have tried all .htaccess answers from comments and none of them worked, it’s possible that actually you have bad APP_URL in you .env config file.
That worked for me.
answered Oct 23, 2019 at 21:45
0
For my case was encountering this issue with Laravel 6.x and managed to sort it out by installing an SSL Certificate. Tried playing around with .htaccess but never worked. I’m using the default Laravel 6.x .htaccess file which has the following contents
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
answered Mar 9, 2020 at 15:05
1
Check your project root directory index.php file. I think your index.php file missing.
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
then check your project root directory .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I hope your problem solved thank you.
answered Jun 16, 2022 at 4:25
Remember that Laravel’s project root is /public
The solution for me was so simple it was silly — I had moved my folders and updated the paths in my Apache server’s virtual hosts configuration (extra/httpd-vhosts.conf
for XAMPP), but had forgotten that Laravel’s app root is located at /public
. Simply updating:
D:\Users\Me\Documents\Projects\Websites\myproject
to
D:\Users\Me\Documents\Projects\Websites\myproject\public
…and then restarting the server solved the issue.
answered Jul 1, 2022 at 19:49
Hashim AzizHashim Aziz
4,1155 gold badges38 silver badges68 bronze badges
In my case, the index.php
file was missing from the Laravel root project, this also caused 403 error forbidden, creating a new file and put this code on it got the job done.
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
answered Jul 24, 2022 at 8:30
WardNsourWardNsour
3131 gold badge2 silver badges16 bronze badges
I had the same problem and builded a .htaccess
file to fix this issue with a few more improvements. You can use it as it is, just download it from Github Gist and change the filename «public/index.php» to «public/app.php» and see how it works!
answered Jul 3, 2015 at 20:21
dudedude
5,68811 gold badges54 silver badges81 bronze badges
For me this was simply calling route()
on a named route that I had not created/created incorrectly. This caused the Forbidden error page.
Restarting the web server allowed proper Whoops! error to display:
Route [my-route-name] not defined.
Fixing the route name ->name('my-route-name')
fixed the error.
This is on Laravel 5.5 & using wampserver.
answered Mar 3, 2018 at 2:46
AndrewAndrew
18.8k13 gold badges104 silver badges118 bronze badges
I had this error and i just pasted the http://127.0.0.1:8000/ directly into the url bar.
you get the below when you type : php laravel serve
i was putting in localhost/http://127.0.0.1:8000/ to get the error you mentioned.
answered Nov 26, 2018 at 0:01
On public/.htaccess edit to
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
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>
In the root of the project add file
Procfile
File content
web: vendor/bin/heroku-php-apache2 public/
Reload the project to Heroku
bash
heroku login
cd my-project/
git init
heroku git:remote -a my project
git add .
git commit -am "make it better"
git push heroku master
heroku open
Theo
57.8k8 gold badges24 silver badges41 bronze badges
answered Aug 6, 2019 at 11:37
0
The problem is the location of the index file (index.php).You must create a symbolic link in the root of the project to public/index.php with the command «ln-s public/index.php index.php«
answered Sep 5, 2019 at 12:24
Heretic SicHeretic Sic
3742 silver badges9 bronze badges
You might be facing the file permissions issue. Verify your htacces file, did it change from yesterday ? Also, if you were doing any «composer update» or «artisan optimize» stuff, try chowning your laravel project folder for your username.
chown -R yourusername yourlaravelappfolder
EDIT: the problem is possibly due to your local file permissions concerning Vagrant. Try to
set the permissions to the Vagrantfile containing folder to 777
answered Aug 16, 2013 at 11:47
GadomaGadoma
6,4751 gold badge31 silver badges34 bronze badges
7
I’ve found solution
I put following code into my public/.htaccess
and now its running at rocket speed
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
answered Jan 13, 2020 at 8:30
1
My laravel installation was working fine yesterday but today I get the following error:
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Does anyone know where I am going wrong?
asked Aug 16, 2013 at 11:44
2
Create and put this .htaccess file in your laravel installation(root) folder.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
answered Apr 20, 2015 at 13:12
AlexeyAlexey
7,1479 gold badges57 silver badges94 bronze badges
4
For me, It was just because I had a folder in my public_html named as same as that route!
so please check if you don’t have a folder with the address of that route!
hope be helpful
answered Sep 3, 2018 at 4:16
AliAli
1,5251 gold badge16 silver badges27 bronze badges
5
I met the same issue, then I do same as the solution of @lubat and my project work well.
My virtualhost configuration:
<VirtualHost *:80>
ServerName laravelht.vn
DocumentRoot D:/Lavarel/HTPortal/public
SetEnv APPLICATION_ENV "development"
<Directory D:/Lavarel/HTPortal/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
answered Oct 8, 2015 at 8:06
0
Check your virtual host configuration.
For Ubuntu you could find it at /etc/apache2/sites-available/yourlaravel.conf
It should be like this:
<VirtualHost *:80>
ServerName yourlaravel.com
DocumentRoot "/path/to/your/laravel/project/public"
ServerAlias *.yourlaravel.com
<Directory "/path/to/your/laravel/project/public">
AllowOverride All
Require all granted
</Directory>
The key line is Require all granted
inside <Directory>
.
Hope it helps!
answered Jul 30, 2015 at 10:21
lubartlubart
1,7463 gold badges27 silver badges35 bronze badges
Just add a .htaccess
file in your root project path with the following code to redirect to the public folder:
.HTACCESS
## Redirect to public folder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
Very simple but work for me in my server.
Regards!
answered Apr 3, 2018 at 17:57
3
Have you tried to change the .htaccess file that laravel suggested if the default one doesn’t work? I had this similar problem and changed it to
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
and it soleved
answered Aug 17, 2013 at 7:34
2
It was solved for me with the Laravel default public/.htaccess file adding an extra line:
The /public/.htaccess
file remains as follows:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
DirectoryIndex index.php # <--- This line
# 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>
answered Jul 20, 2016 at 20:41
EvhzEvhz
8,8519 gold badges51 silver badges69 bronze badges
0
For those who using Mamp or Mamp pro:
Open MAMP Pro
Click on “Hosts”
Click on “Extended” (UPDATE: Only if you are using MAMP Pro 3.0.6)
Check “Indexes”
Click “Save”
That’s it! Reload your localhost starting page and it should work properly.
answered Dec 28, 2014 at 12:30
DixitDixit
12.7k3 gold badges49 silver badges46 bronze badges
0
With me the problem appeared to be about the fact that there was no index.php file in the public_html folder. When I typed in this address however: http://azxcvfj.org/public , it worked (this address is just an example. It points to nowhere). This made me think and eventually I solved it by doing the following.
I made a .htaccess file in the app’s root folder (the public_html folder) with this contents:
<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 ^ public/index.php [L]
</IfModule>
And this worked. With this file you are basically saying to the server (Apache) that whenever someone is trying to access the public html folder(http://azxcvfj.org) that someone who is being redirected is redirected to http://azxcvfj.org/public/index.php
answered Nov 9, 2014 at 17:26
PieterVKPieterVK
1,4811 gold badge10 silver badges4 bronze badges
First, update your Virtual Host configuration;
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html/example-project/public
<Directory /var/www/html/example-project/public/>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Then, change both permission and ownership of the asset as illustrated below.
$ sudo chgrp -R www-data /var/www/html/example-project
$ sudo chmod -R 775 /var/www/html/example-project
nyedidikeke
6,9378 gold badges44 silver badges59 bronze badges
answered Aug 20, 2017 at 16:56
YvesYves
80715 silver badges17 bronze badges
In your VirtualHost write the DocumentRoot to point to your Laravel Application in your home directories. In addition you must add the Directory shown below, with your own path:
<Directory /home/john/Laravel_Projects/links/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
The second step, you must go to your Laravel Project and run the following command.
sudo chmod -R 777 storage bootstrap/cache
At the end restart your apache2:
sudo service apache2 restart
answered Dec 5, 2018 at 4:31
2
This is solved my problem by adding this line:
DirectoryIndex index.php
Grant Miller
27.6k16 gold badges147 silver badges165 bronze badges
answered Jun 3, 2018 at 0:18
In my case, this error was due to internal links in the server, PHP wasn’t able to access those folders unless the proper option for that was added to .htaccess
.
Add the following line after RewriteEngine On
:
Options +FollowSymLinks
answered Nov 19, 2019 at 17:53
António AlmeidaAntónio Almeida
9,6408 gold badges59 silver badges66 bronze badges
1
Chances are that, if all the answers above didn’t work for you, and you are using a request validation, you forgot to put the authorization to true.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class EquipmentRequest extends FormRequest {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() {
/*******************************************************/
return true; /************ THIS VALUE NEEDS TO BE TRUE */
/*******************************************************/
}
/* ... */
}
answered Jun 4, 2018 at 14:15
Amin NAIRIAmin NAIRI
2,30221 silver badges20 bronze badges
1
If you have tried all .htaccess answers from comments and none of them worked, it’s possible that actually you have bad APP_URL in you .env config file.
That worked for me.
answered Oct 23, 2019 at 21:45
0
For my case was encountering this issue with Laravel 6.x and managed to sort it out by installing an SSL Certificate. Tried playing around with .htaccess but never worked. I’m using the default Laravel 6.x .htaccess file which has the following contents
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
answered Mar 9, 2020 at 15:05
1
Check your project root directory index.php file. I think your index.php file missing.
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
then check your project root directory .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I hope your problem solved thank you.
answered Jun 16, 2022 at 4:25
Remember that Laravel’s project root is /public
The solution for me was so simple it was silly — I had moved my folders and updated the paths in my Apache server’s virtual hosts configuration (extra/httpd-vhosts.conf
for XAMPP), but had forgotten that Laravel’s app root is located at /public
. Simply updating:
D:\Users\Me\Documents\Projects\Websites\myproject
to
D:\Users\Me\Documents\Projects\Websites\myproject\public
…and then restarting the server solved the issue.
answered Jul 1, 2022 at 19:49
Hashim AzizHashim Aziz
4,1155 gold badges38 silver badges68 bronze badges
In my case, the index.php
file was missing from the Laravel root project, this also caused 403 error forbidden, creating a new file and put this code on it got the job done.
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
answered Jul 24, 2022 at 8:30
WardNsourWardNsour
3131 gold badge2 silver badges16 bronze badges
I had the same problem and builded a .htaccess
file to fix this issue with a few more improvements. You can use it as it is, just download it from Github Gist and change the filename «public/index.php» to «public/app.php» and see how it works!
answered Jul 3, 2015 at 20:21
dudedude
5,68811 gold badges54 silver badges81 bronze badges
For me this was simply calling route()
on a named route that I had not created/created incorrectly. This caused the Forbidden error page.
Restarting the web server allowed proper Whoops! error to display:
Route [my-route-name] not defined.
Fixing the route name ->name('my-route-name')
fixed the error.
This is on Laravel 5.5 & using wampserver.
answered Mar 3, 2018 at 2:46
AndrewAndrew
18.8k13 gold badges104 silver badges118 bronze badges
I had this error and i just pasted the http://127.0.0.1:8000/ directly into the url bar.
you get the below when you type : php laravel serve
i was putting in localhost/http://127.0.0.1:8000/ to get the error you mentioned.
answered Nov 26, 2018 at 0:01
On public/.htaccess edit to
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
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>
In the root of the project add file
Procfile
File content
web: vendor/bin/heroku-php-apache2 public/
Reload the project to Heroku
bash
heroku login
cd my-project/
git init
heroku git:remote -a my project
git add .
git commit -am "make it better"
git push heroku master
heroku open
Theo
57.8k8 gold badges24 silver badges41 bronze badges
answered Aug 6, 2019 at 11:37
0
The problem is the location of the index file (index.php).You must create a symbolic link in the root of the project to public/index.php with the command «ln-s public/index.php index.php«
answered Sep 5, 2019 at 12:24
Heretic SicHeretic Sic
3742 silver badges9 bronze badges
You might be facing the file permissions issue. Verify your htacces file, did it change from yesterday ? Also, if you were doing any «composer update» or «artisan optimize» stuff, try chowning your laravel project folder for your username.
chown -R yourusername yourlaravelappfolder
EDIT: the problem is possibly due to your local file permissions concerning Vagrant. Try to
set the permissions to the Vagrantfile containing folder to 777
answered Aug 16, 2013 at 11:47
GadomaGadoma
6,4751 gold badge31 silver badges34 bronze badges
7
I’ve found solution
I put following code into my public/.htaccess
and now its running at rocket speed
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
answered Jan 13, 2020 at 8:30
1
Hello Friends 👋,
Welcome To Infinitbility! ❤️
Today, we are going to fix 403 forbidden error in laravel, here we will see causes of laravel 403 errors and their apropriate solutions.
Currently, we have 2 cases when 403 forbidden error occure, if we got any new case we will also update this post.
Let’s see how laravel forbidden error looks like, where we get this error?
after setup, when you try to run your laravel application, you will get screen looks live above screen shot.
Okey, let’s start today’s topic How to solve 403 forbidden error in laravel?
Here, we are going to solve below cases
.htaccess
file issue- Public folder name issue
.htaccess
file issue
Majorly, developers face issue due to mis configuration of .htaccess
file.
some are put this file in wrong folder, and some have .htaccess
code not covering RewriteRule
and RewriteCond
.
Let’s see right way to conigure .htaccess
file.
-
Create
.htaccess
file in your project root folder, again here I’m saying root folder not the Public folder. -
put below
.htaccess
code in your.htaccess
file.<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L] </IfModule>
After done this try to access your project in browser. it shuld show your project.
Public folder name issue
Sometimes, some route showing 403 forbidden error and whole website working fine.
it’s occure due to same route name already available in public folder.
you have to write different route name or folder name in public folder.
I hope it’s help you, All the best 👍.
Laravel error 403 is one of the most common and annoying errors.
It mainly occurs due to improper permissions, ownerships, or any trouble with the .htaccess file and also missing directives.
Here at Bobcares, we usually receive many requests for fixing Laravel errors as a part of our Server Management Services.
Today, let’s see how our Support Engineers fix it.
How we fix Laravel error 403
Now let’s now see how our Support Engineers fix this error efficiently.
1. Check the permissions and ownership
Whenever we receive this error our Support Engineers initially check the permissions and ownerships of the files and folders.
And confirm that the permissions and the ownership of the files and folders are set correctly because this is one of the common reasons for this error to occur.
2. Checking the .htaccess file.
The .htaccess file also plays a major role in throwing the error message. So, we check if there are any incorrect codes in it. If so, then we either remove the code or rename the .htaccess file.
Here is the command that we run to rename the .htacess file.
mv .htaccess .htaccess-bck
3. Missing directives
Recently, one of our customers approached us with this error message on his Laravel website.
After fixing the permissions and checking the .htaccessfile, we checked for the virtual host configuration file httpd.conf placed in the path /etc/httpd/conf.d. We could see that the AllowOverride directive was missing in the configuration file.
Hence, the .htaccess file was not getting parsed by apache because the AllowOverride All directive was missing.
So, we added the below code in the virtual host configuration file.
Then we restarted Apache using the command
service httpd restart
After this, we cleared the cache and cookies. Finally, we could see the website to be working well and the error 403 disappeared.
[Need assistance in fixing Laravel errors? – We’ll help you]
Conclusion
In short, this error mainly occurs due to bad permissions, improper ownerships and incorrect .htaccess file. Today, we saw how our Support Engineers fix this error message.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
GET STARTED
var google_conversion_label = «owonCMyG5nEQ0aD71QM»;
Установил laravel, при переходе по адресу https:// site.ru выдает такую ошибку, если же перейти по адресу https:// site.ru/public/index.php то сайт отображается. Содержимое файла .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
С чем связанна данная ошибка?
-
Вопрос задан
-
8394 просмотра
Очевидно, что у вас неправильно настроены пути на веб-сервере: домен стучится в папку, которая не является документ-рутом и вы видите 403. Настройте веб-сервер так, чтобы он смотрел в папку public.
Посмотрите по ссылке настройки: https://stackoverflow.com/questions/18272557/larav…
Проблема в настройке веб сервера он должен как корень видеть папку public, а видит корень проекта
Вот к примеру настройка для nginx
server {
...
root /var/www/site.ru; //так у тебя
root /var/www/site.ru/public; //так надо
...
Ну и для Apache
<Directory /var/www/site.ru/> //так у тебя
<Directory /var/www/site.ru/public/> //так надо
Пригласить эксперта
-
Показать ещё
Загружается…
21 сент. 2023, в 08:33
10000 руб./за проект
21 сент. 2023, в 08:28
47000 руб./за проект
21 сент. 2023, в 07:57
20000 руб./за проект