D
D
Dmitriy2020-01-19 23:27:51
PHP
Dmitriy, 2020-01-19 23:27:51

Style connection error due to Router?

There was a problem, styles on other pages are not connected.
1. The structure of my project.
project
==app
=views
=layouts
=default.php (Standard template: header and footer, styles are connected in the header .)
=Main
=index.php ( Content is displayed here )
=public
=css
=js
=index.php( This is the point login to the application, requests all go here)
=.htaccess ( htaccess number 2 )
.htaccess ( htaccess number 1 )
.htaccess number 1
File in the root of the site: project/.htaccess

AddDefaultCharset utf-8
RewriteEngine On
RewriteRule ^(.*)$ public/$1

.htaccess number 2
File in public folder: project/public/.htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

default.php
The file where styles are included.
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Title of the website</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/bootstrap.min.css">
</head>

Styles are enabled on the main page ( project/ ), but not on the other pages ( project/login ).
How to fix?
UPD: SOLVED

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-01-20
@FanatPHP

If you format the directory structure inserted with crooked hands,

=app
    =views
        =layouts
             =default.php ( Стандартный шаблон: хэдэр и футер, в хэдере подключаются <b>стили</b>.)
        =Main
             =index.php  ( Здесь выводится контент )
=public
    =css
    =js
    =index.php( Это точка входа в приложение, запросы все сюда идут )
    =.htaccess  ( <b>htaccess number 2</b> )
.htaccess ( <b>htaccess number 1</b> )

Then it becomes obvious that the css folder is not in the root of the site.
The normal solution would be to make public the root of the site

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question