The requested URL was not found on this server - laravel

Environment
Laravel Version : 4.2.17
PHP Version : 5.6.1
MAC OS X : 10.11
MAMP : 3.5
Description
The project loading fine on home page.
Anything else, but that I got this.
The requested URL /login was not found on this server.
Attempt
check routes
I have that routes declared in my routes.php file
Route::get('login',array('as' => 'login', 'uses' => 'AuthController#showLogin'));
apache settings
MAMP > Apache Settings
<Directory />
Options Indexes FollowSymLinks
AllowOverride All <--- I've changed from 'None' -> 'All'
</Directory>
Restart my MAMP, and same error occur
Question
Why do my server kept throwing me that error ?
What should I check ? Apache Settings of my MAMP ? or my PHP ? or my Laravel ?

After stuck on this more than a day, I've learned that I don't have .htaccess in my public\ folder of my laravel project.
I created a public\.htaccess with this content in there
<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>
Reboot my MAMP
All of that nonsense is no-longer happening.
Hope this answer help someone like me

Related

My Laravel display main page but the rest not found in nginx server using aapanel

I have Laravel 6 running well on my localhost but when I deploy on domainsite.com, it only shows the main page but the rest of links shows 404 page not found. I am using CentOS 7, aaPanel running nginx server. PHP 7.4 MySQL.
I have this config so far.
URL Rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
fileinfo installed
I have removed in Disabled Functions(putenv and symlink) but still I get the error.
Anyone have tried this? Thank you!

Accidental chmod 777 on laravel files made the custom app throw forbidden error in shopify store admin

The title says everything. It's a laravel setup running on apache. I have full root terminal access. Managed to wreck the permissions and now the app just shows the 'Forbidden' message for the /authenticate/token route.
Tried all different kinds of permission arrangements for directories and files. Confirmed ownership by apache and tried ownership by sudo user on selective files too. Disabled selinux as well
Don't remember how but something gave me a hint that the problem might have something to do with the session files in /storage/frameworks/sessions.
Weird bit, sometimes the app magically loads, but most times it doesn't.
Help?
EDIT: Made a mistake while checking details. The route for which the Forbidden message comes is "https://[domain]/?host=[...]&shop=[...]&token=[...]". The route I mentioned above is actually the referring URL.
EDIT:
.htaccess from /public folder
<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>
Error Screen in Shopify Admin (Dev Store)
Laravel Error Log: Clean
Apache Error Log: "[evasive20:error] client denied by server configuration: /var/www/[laravel-folder]/public/, referrer [same path as the previous edit]"
EDIT: Apache server/vhost config:-
<VirtualHost *:80> //don't worry about this, after routing through ngrok's tunnel it comes out as https
ServerAdmin [email]
ServerName [url]
DocumentRoot /var/www/contact-us/public
<Directory /var/www/contact-us/public>
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
firstly you try this:
php artisan storage:link
And make sure that you have all of the folders in your
storage/framework:
sessions
views
cache

Laravel show blank page in local ubuntu 20

I am using ubuntu 20, laravel project run using php artisan serve but when I access the site using this URL laravel-local.com it shows blank page
Could not get any error
sites-available
<VirtualHost *:80>
ServerAdmin admin#MyWebsite.com
DocumentRoot /var/www/html/laravel-local.com/public
ServerName laravel-local.com
<Directory /var/www/html/laravel-local.com/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What I tried
Give project 777 access
Change the ownership
Delete the folder inside the storage/framework
Change the storage folder permission
composer dump-autoload, php artisan cache and config clear
Delete .htaccess file in public folder
I tried all the above steps still got a blank page
.htaccess file in root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
.htaccess in the public folder
<IfModule mod_rewrite.c>
Options -Indexes
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# 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>
sites-available
UPDATE: Your vHost config should be defined in "sites-enabled" for the config to actually be applied. Create a symlink from "sites-enabled" to the actual config file in "sites-available". And restart Apache.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
You don't need an .htaccess file like this (which would need to go in the directory above the /public directory) because you have already configured the /public directory as the DocumentRoot in the server config.
If you had also deleted the .htaccess file inside the /public subdirectory then this would have resulted in a rewrite-loop (500 error).
You just need the standard Laravel front-controller (.htaccess file) inside the document root, ie. in the /public subdirectory.
However, you should define the DirectoryIndex (if not already set somewhere in the server config), either in your vHost (<Directory> container) or at the top of your main Laravel .htaccess file (inside the /public folder). If this is not defined then requests to the Laravel directory itself (the homepage) will not be routed through Laravel and will likely result in a 403 Forbidden response (or worse, a directory listing if Indexes have been enabled) from Apache.
For example:
DirectoryIndex index.php

Laravel version 5.7 root show index of page

Recently I am start using Laravel, and I develop a website in my local which works fine, but when I deploy it to a droplet in DigitalOcean, the root shows an index Of page.
Screen Capture is here
And when I navigate into the public folder, it shows a 500 error.
I have tried to include a few different .htaccess, which does not solve the problem. And my current .htaccess is below
DirectoryIndex index.php
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
The line "Options -MultiViews" is actually part of the .htaccess code too.
Could anyone please help me to solve this problem?
Thank you in advance.
See more here
In the server config file is the AllowOverride set to All or None? If its set to none all .htaccess changes will be ignored.
<Directory /var/www/YOURAPP/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Don't forget to generate a key...
php artisan key:generate
https://laravel.com/docs/5.7/installation

mod_rewrite redirects to .html in error

I've just setup an AMP server on OSX 10.9 and have a bizzare problem which is not present on my live hosting server or my old WAMP server.
I want to redirect any URL that doesn't directly map to a file on the server to index.php. I'm using the following .htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# prevent loop
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*)$ /index.php?/$1 [L]
when I try http://example.com/example there is no problem, but when I introduce another slash, for example, http://example.com/example/
I get the a 404 error The requested URL /example.html/ was not found on this server.
Server version: Apache/2.2.26 (Unix)
Looks like your problem is related to enabling of MultiViews here. Turn it off by using this line on top of your .htaccess:
Options -MultiViews
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.

Resources