A
A
Adik Izat2020-08-19 14:28:26
htaccess
Adik Izat, 2020-08-19 14:28:26

How to properly configure .htaccess so that scripts, images, etc. loaded without 404?

Hello! I am writing a bike for a test task. In the conditions of the task, it is worth separating public files and application code. The application itself is almost completely written for me, only scripts and styles are not connected) Here is the structure:
5f3d0c2de41ba068082708.png

When I access "some.site/src/css/bootstrap.min.css" I want the contents of the file "some.site/public/src" /css/bootstrap.min.css", but in fact I see 404.

AddDefaultCharset utf-8

RewriteEngine on
RewriteBase /

RewriteRule ^(.*)$ public/index.php


I tried to write to the rule above: RewriteRule ^src/(.*)$ public/src/$1 [L]but it does not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mega Sinyak, 2020-08-19
@JaxAdam

classic
/.htaccess

RewriteEngine On
RewriteRule ^(.*)$ /public/$0

/public/.htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$0 [L]

move the css and js folders to public (that is, get rid of the src folder), the paths to styles and scripts should look like this /css/bootstrap.min.css, etc.
remove bootstrap.js and popper.js, since all this is already in bootstrap.bundle.js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question