R
R
RoffDaniel2019-07-14 02:30:11
htaccess
RoffDaniel, 2019-07-14 02:30:11

How to fix the display of site elements that are broken due to .htaccess?

Good night Ladies and gentlemen. As far as I'm VERY weak in .htaccess, I generally can't figure it out normally in CNC, I turn to you about this.
I did page routing, but because of this, CSS, IMG, etc. are not displayed for me ...
Here is the code:

RewriteEngine On

RewriteBase /

AddDefaultCharset UTF-8

ErrorDocument 401 /site-system/errors/401.php
ErrorDocument 403 /site-system/errors/403.php
ErrorDocument 404 /site-system/errors/404.php
ErrorDocument 500 /site-system/errors/500.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]
#==============================================================
RewriteRule ^([^/]*)/$ /?page=$1 [L]
#===========================NEWS===============================
RewriteRule ^([^/]*)/([^/]*)/$ /?page=$1&url=$2 [L]
#==============================================================
# RewriteRule ^logout/$ /site-system/functions/logout.php [L]
#==============================================================

What rule should be added? =(
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2019-07-15
@RoffDaniel

1. what about css, what does the debugger say?
2. both rules are needed

############################################################################
#### Убираем слеши в конце URL для статических файлов (содержит точку)  ####
############################################################################
RewriteCond %{REQUEST_URI} \..+$
   # Если файл содержит точку.
RewriteCond %{REQUEST_FILENAME} !-d
   # И это не директория.
RewriteCond %{REQUEST_FILENAME} -f
   # Является файлом.
RewriteCond %{REQUEST_URI} ^(.+)/$
   # И в конце URL есть слеш.
RewriteRule ^(.+)/$ /$1 [R=301,L]
   # Исключить слеш.

############################################################################
#### Добавляем слеш(/), если его нет, и это не файл.                    ####
############################################################################
RewriteCond %{REQUEST_URI} !(.*)/$
   # Если слеша в конце нет.
RewriteCond %{REQUEST_FILENAME} !-f
   # Не является файлом.
RewriteCond %{REQUEST_URI} !\..+$
   # В URL нет точки (файл).
RewriteCond %{REQUEST_URI} ^(.+)$
 # В URL есть хоть один символы
RewriteRule ^(.*)$ $1/ [L,R=301]
   # Добавляем слеш в конце.

D
Dimonchik, 2019-07-14
@dimonchik2013

any with img, css , anyway they are not here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question