Answer the question
In order to leave comments, you need to log in
How to set up 404 correctly so that the site does not come up with urls that do not exist?
Good day to all.
I can't find any error.
I have a site in php.
.htacces and index.php manage redirects and other rules
like this index.php looks like
<?php
mb_internal_encoding("UTF-8");
$action = '';
$arguments = explode('/', $_SERVER['REQUEST_URI']);
$action = "default";
foreach( $arguments as $key => $value ){
if (strpos($value, "utm_")) {
unset($arguments[$key]);
}
}
if (count($arguments) > 1) {
if (!ctype_space($arguments[1]) && !empty($arguments[1])) {
$action = $arguments[1];
}
}
if (count($arguments) > 2) {
$id = $arguments[2];
}
if ($action == "default") {
$pageTitle = "Дизайн интерьера в Киеве под Ключ. Скидка 10% ";
$pageDesc = "Мы создаем дизайны интерьера, которые радуют наших заказчиков. Наши дизайнеры интерьера справятся с любой поставленной задачей в кратчайшие сроки и под Ваш бюджет!";
$pageKeys = "дизайн интерьера киев выгодно ремонт квартир";
$idform = "Заявка с главной страницы";
$headerform = "Обсудить дизайн проект с дизайнером";
include("index_page.php");
}
else if (strtolower($action) != "default"){
$pageTitle = "Страница не найдена |";
include("404.php");
}
DefaultLanguage ru
AddDefaultCharset utf-8
php_value default_charset "utf-8"
php_value date.timezone "Europe/Kiev"
#AddType application/x-httpd-php .php .phar
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html .phtml .phar
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !\?
RewriteCond %{REQUEST_URI} !\&
RewriteCond %{REQUEST_URI} !\=
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !\/$
RewriteRule ^(.*[^\/])$ /$1/ [R=301,L]
RewriteCond %{THE_REQUEST} //
# Проверяем, повторяется ли слеш (//) более двух раз.
RewriteCond %{QUERY_STRING} !http(s|)://
# Убедимся что это не урл в GET
RewriteRule .* /$0 [R=301,L]
# Исключаем все лишние слеши.
#################разрешаем фейсбуку разметку ссылок для рекламы блять##############################################################
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)fbclid=(?:[^&]*)((?:&|$).*)$ [NC]
RewriteCond %1%2 (^|&)([^&].*|$)
RewriteRule ^(.*) $1?%2 [R=301,L]
#############################################################
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)gclid=(?:[^&]*)((?:&|$).*)$ [NC]
RewriteCond %1%2 (^|&)([^&].*|$)
RewriteRule ^(.*) $1?%2 [R=301,L]
#RewriteRule ^/tmp/([^\.]+)\.(png|jpg|gif)$ /image.php?file=$1.$2 [NC,L]
RewriteCond %{REQUEST_URI} !^([\d\w\-\/\:\.]*(?:\.jpg|\.jpeg|\.png|\.ico|\.tif))$ [NC]
RewriteCond %{REQUEST_URI} !^([\d\w\-\/\:\.]*(?:\.css|\.js|\.eot|\.svg|\.ttf|\.woff|\.woff2|\.map))$ [NC]
RewriteCond %{REQUEST_URI} !^([\d\w\-\/\:\.]*(?:\.pdf|\.txt|\.html|\.xml))$ [NC]
#RewriteCond %{REQUEST_URI} !^([\d\w\-\/\:\.]*(?:\.phar|\.php))$ [NC]
RewriteCond %{REQUEST_URI} !^([\d\w\-\/\:\.]*(?:\.ogm|\.ogv|\.ogg|\.webm|\.mp4))$ [NC]
RewriteRule . index.php [L,QSA]
AddType video/ogg .ogm
AddType video/ogg .ogv
AddType video/ogg .ogg
AddType video/webm .webm
AddType video/mp4 .mp4
ErrorDocument 404 /404.php
</IfModule>
<IfModule mod_deflate.c>
AddType image/svg+xml .svg
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/svg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
<filesmatch "\.(ico|flv|jpg|jpeg|webp|png|gif|css|swf)$">
Header set Cache-Control "max-age=31536000, public"
</filesmatch>
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
<filesmatch "\.(js|otf|ttf|woff|woff2)$">
Header set Cache-Control "max-age=31536000, private"
</filesmatch>
</IfModule>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question