R
R
RadionOdessa2020-11-11 20:28:35
Software Deployment
RadionOdessa, 2020-11-11 20:28:35

How to run laravel project without php artisan serve without changing project structure(folder nesting) without renaming server.php to index.php?

Help to launch a laravel project on a hosting, but which does not have the ability to specify a folder with index.php
Options:
1. rename server.php to index.php in the laravel root directory.
Just copy the .htaccess file from the public folder to the root of the project, and update it as shown below:
Options -MultiViews -Indexes

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_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*) $ public/$1/$2 [L,NC]

Result - empty page

2. At the root of the .htaccess directory
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Result - no styles included

It is necessary not to change the structure of the project. Only the variant with the correct .htaccess code is suitable. Everything that I found on the Internet did not help. Either styles are not loaded, or a blank page.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question