laravel 5 https always 404 for any route - php

I have laravel 5 running ubuntu on aws with apache2. The site and route works with no http.
When hit e.g. https://example.com, only the home page works. The other pages returns 404. e.g. https://example.com/home returns 404
.htaccess
<IfModule mod_rewrite.c>
<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>
the 000-default.conf
the ssl.conf
The servername don't have be there for aws to work.

based on this: How can I fix Laravel 5.1 - 404 Not Found?
the ssl conf need to "mirror" 000-default.conf. i.e.
<Directory>
......
</Directory>
This part needs to copy to the apache ssl conf from 000-default.conf

Related

deploying codeigniter 4 in shared hosting public assets results to a 404

I have a fresh setup of codeigniter 4 project, which works well locally, I am able to load assets.
When i uploaded it online, assets fails to load, leading to a 404, but I am able to load the views.
This is my htaccess that came default with the codeigntier files within public:
# Disable directory browsing
Options All -Indexes
# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------
# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
# RewriteBase /
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]
# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>
# Disable server signature start
ServerSignature Off
# Disable server signature end
and this is an update i made to root path which made the views to work, but initially instead of views I was just seeing the directory index of:
DirectoryIndex /public/index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./public/index.php/$1 [L,QSA]
so I now have two htaccess, one in root which is public_html and one within public
but still assets fails to load.

Multiple Laravel project htaccess

I have a problem with .htaccess configuration for multiple Laravel projects on my Apache webserver. One project in the root folder and one project in a subfolder
File structure (/www)
/ <-- Laravel application #1
/anotherProject <-- Laravel application #2
When I'm visiting www.example.com/anotherProject then I get a 404 error (and www.example.com is working. The following .htaccess is activate in /public/ (for Laravel application #1).
/public/.htaccess
<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>
It feels like I need to change something in the .htaccess file of the project in the root folder. Has someone a suggestion to try?

How to prevent HTTPS reditrect on xampp for laravel

I have made virtual server for Laravel 5.4 project, it is laravel.cs when I open homepage it opens http://laravel.cs but when I click on any other link it opens with HTTPs therefore getting 404 Error.
.htacess file
# Laravel 5 Rewrites
<IfModule mod_rewrite.c>
<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>
I also tried by SSL engine OFF in xampp httpd-ssl-conf, but not worked

Laravel 5.3 Route NotFoundHttpException

I have deployed my Laravel 5.3 application on an AWS server running Ubuntu and php 7. i have created an alias in the /etc/apache2/sites-available/000-default.conf file as below:
Alias /myapp.dev /var/www/html/myapp/public/
<Directory "/var/www/html/myapp/public/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /var/www/html/myapp/public/
</Directory>
But when i try to access with the alias as 52.xxx.xxx.xx/myapp.dev i get the following error:
How ever when i access it with full url to the public/ directory it works fine
eg. 52.xxx.xxx.xx/myapp.dev/public/login
I have enabled a2enmod and my .htaccess file in /public directory is as below
<IfModule mod_rewrite.c>
<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}]
any ideas as to why i am getting the Route NotFoundHttpException in my aws server and not to forget to mention that in my local windows machine running php 5.6 also is running fine with a vhost. Your ideas are very much appreciated. Thanks in advance
Try this .htaccess. Hope it will help.
<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>

Don't work admin-panel and authorization in laravel5.3's project

I make admin-panel at laravel 5.3. I try to install sleepingowl 4. All project I make according to the official documentation.All project operate as expected (http://blog.laravel/). But...if I go the link
http://blog.laravel/admin
than apache issues :
Not Found
The requested URL /admin was not found on this server.
After I try to use authorization. I make new project which named "auth". But ... if I go the link:
http://auth/signup
apache issues too...:
Not Found
The requested URL /signup was not found on this server.
All rights are open to write-rewrite. All my steps according of the oficcial documentation :
https://laravel.com/docs/5.3/installation
I don't know what I doing wrong. Please, tell me what can I do
There are the links of github:
https://github.com/AlexBukreyev/blog.laravel - this is my project, where I make admin-panel.
https://github.com/AlexBukreyev/auth - this is project of authorization
file public /.htaccess:
<IfModule mod_rewrite.c>
<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>
Make sure in public directory, there is a file called .htaccess (with the dot . at the begining). The content of that file should look like this:
<IfModule mod_rewrite.c>
<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>
It turned out, it was in the settings of the Apache! You need to connect mod_rewrite through the console:
apache2ctl -M | grep -i rew
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart

Categories