N
N
NikSIk312019-09-02 23:38:08
Apache HTTP Server
NikSIk31, 2019-09-02 23:38:08

.htaccess for laravel knocked paths?

Added to root .htaccess with

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ ^$1 [N]

    RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
    RewriteRule ^(.*)$ public/$1

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ server.php
</IfModule>

but after the update with clearing the cache, nothing is loaded from pictures, js, css. Only if you add public before the path, then it will start. How it is possible to correct it or all ways to change?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Gorbunov, 2019-09-03
@leha_gorbunov

How to run laravel on shared hosting.
1. You upload the public content to the hosting root folder, which opens at the site address.
2. In the same root folder, create another one (for example, you call it laravel)
3. Copy all other files and folders from the project (app, etc.) to the new folder (laravel), except for public .
4. In the root folder of the site, open index.php and change 2 lines with path configs to the following code.

....
require $_SERVER['DOCUMENT_ROOT'].'/laravel/vendor/autoload.php';
....
$app = require_once $_SERVER['DOCUMENT_ROOT'].'/laravel/bootstrap/app.php';

And everything works without editing .htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question