Задать вопрос
@webrapinfo

Как настроить вывод 404 ошибки через htaccess?

Добрый день нужна помощь эксперта. Есть фаил .htaccess хочу через него настроить вывод кода 404 для страниц которых не существует.
Пример страниц:
https://zctc.ru/addadsasdas/
https://zctc.ru/12311454141
Сейчас отдает просто 200 код и открывает главную страницу
Содержимое файла htaccess
AddDefaultCharset UTF-8
ErrorDocument 404 /sections/404

RewriteEngine on

RewriteCond %{QUERY_STRING} (?:^|&)section=([^&]+)
RewriteRule ^$ https://zctc.ru/sections/%1? [R=301,L]

RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond ${REQUEST_FILENAME} !-f

# Каталог товаров
RewriteRule ^catalog/([^/]+)/([^/]+)/([^/]+)/foto/?$ index.php?module=ProductFoto&product=$3 [L]

RewriteRule ^catalog/([^/]+)/([^/]+)/page_([^/]+)/?$ index.php?module=Storefront&category=$1&brand=$2&page=$3 [L]
RewriteRule ^catalog/([^/]+)/page_([^/]+)/?$ index.php?module=Storefront&category=$1&page=$2 [L]
RewriteRule ^catalog/([^/]+)/([^/]+)/?$ index.php?module=Storefront&category=$1&brand=$2 [L]
RewriteRule ^catalog/([^/]+)/?$ index.php?module=Storefront&category=$1 [L]
RewriteRule ^catalog/?$ index.php?module=Storefront& [L]

RewriteRule ^products/([^/]+)/?$ index.php?module=Storefront&product=$1 [L]
RewriteRule ^products/?$ index.php?module=Storefront [L]

RewriteRule ^brands/?$ index.php?module=Storefront [L]
RewriteRule ^brands/([^/]+)/?$ index.php?module=Storefront&brand=$1 [L]

# Поиск товаров
RewriteRule ^search/([^/]+)/?$ index.php?module=Search&keyword=$1 [L]
RewriteRule ^search/?$ index.php?module=Search [L]

# Поиск матерьялов
RewriteRule ^search_materials/([^/]+)/?$ index.php?module=SearchMaterials&keywordmaterials=$1 [L]
RewriteRule ^search_materials/?$ index.php?module=SearchMaterials [L]

# Страницы
RewriteRule ^sections/([^/]+)/?$ index.php?section=$1 [L]

# Статьи
RewriteRule ^articles/([^/]+)/?$ index.php?module=Articles&article_url=$1 [L]
RewriteRule ^articles/?$ index.php?module=Articles [L]

# Новости
RewriteRule ^news/([^/]+)/?$ index.php?module=NewsLine&news_url=$1 [L]
RewriteRule ^news/?$ index.php?module=NewsLine [L]

# Корзина и заказы
RewriteRule ^cart/?$ index.php?module=Cart [L]
RewriteRule ^cart/add/([^/]+)/?$ index.php?module=Cart&product_id=$1 [L]
RewriteRule ^cart/delete/([^/]+)/?$ index.php?module=Cart&delete_product_id=$1 [L]
RewriteRule ^order/([^/]+)/?$ index.php?module=Order&order_code=$1 [L]
RewriteRule ^order/?$ index.php?module=Order [L]

# Для пользователей
RewriteRule ^logout/?$ index.php?module=Login&action=logout [L]
RewriteRule ^login/remind/?$ index.php?module=Login&remind=1 [L]
RewriteRule ^login/?$ index.php?module=Login [L]
RewriteRule ^account/?$ index.php?module=Account [L]
RewriteRule ^registration/?$ index.php?module=Registration [L]

# google sitemap
RewriteRule ^sitemap.xml?$ index.php?module=Sitemap [L]

# pricelists
#RewriteRule ^pricelist.xls?$ index.php?module=Pricelist [L]
#RewriteRule ^yandex.xml?$ index.php?module=Pricelist&format=yandex [L]

# feedback
RewriteRule ^feedback/?$ index.php?module=Feedback [L]

#downloads
RewriteRule ^order/([^/]+)/([^/]+)/?$ download.php?order_code=$1&file=$2 [L]

#RewriteCond %{REQUEST_URI} ^(.*?)\/{2,}(.*?)$
#RewriteRule . %1/%2 [L,R=301]
#RewriteCond %{THE_REQUEST} //
#RewriteRule .* /$0 [R=301,L]

# HTTPS redirect from HTTP
RewriteCond %{HTTP_HOST} ^zctc\.ru [NC]
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^www.zctc.ru$ [NC]
RewriteRule ^(.*)$ https://zctc.ru/$1 [R=301,L]

RewriteCond %{THE_REQUEST} /(.*)index.php.*$
RewriteCond %{THE_REQUEST} !/admin/
RewriteRule .* /%1 [R=301,L]

RewriteCond %{THE_REQUEST} /(.*)index.html.*$
RewriteCond %{THE_REQUEST} !/admin/
RewriteRule .* /%1 [R=301,L]

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]



# Add correct content-type for fonts & SVG
AddType application/font-woff2 .woff2
AddType image/svg+xml .svg

ExpiresActive On
ExpiresDefault "access plus 5 seconds"

# Cache Images
ExpiresByType image/x-icon "access plus 1209600 seconds"
ExpiresByType image/jpeg "access plus 1209600 seconds"
ExpiresByType image/png "access plus 1209600 seconds"
ExpiresByType image/webp "access plus 1209600 seconds"
ExpiresByType image/gif "access plus 1209600 seconds"
ExpiresByType image/svg+xml "access plus 1209600 seconds"

# Cache Fonts
ExpiresByType application/font-woff2 "access plus 1209600 seconds"
ExpiresByType image/svg+xml "access plus 1209600 seconds"

# Cache other content types (CSS, JS, HTML, XML)
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 1209600 seconds"
ExpiresByType application/javascript "access plus 1209600 seconds"
ExpiresByType application/x-javascript "access plus 1209600 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"





AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript application/font-woff2 image/svg+xml



Redirect 301 /sections/uslugi https://zctc.ru/

Redirect 301 /uslugi https://zctc.ru/

Redirect 301 /?section=chrome%252520at%252520home https://zctc.ru/sections/chrome%20at%20home
  • Вопрос задан
  • 147 просмотров
Подписаться 1 Простой 2 комментария
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы