E
E
eratnikstudio2018-08-23 12:39:39
Joomla
eratnikstudio, 2018-08-23 12:39:39

How to redirect non-existent pages to error.php page in .htaccess file?

Hello. How to correctly set up a redirect of non-existent pages to the error.php page in the .htaccess file? Now, if you follow this link (for example) https://livion.ru/scsdcsd, a duplicate of this page is created, but you need to go to https://livion.ru/error. With such a link - https://livion.ru/1 goes to https://livion.ru/error. What to do?)
Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Notan Royamov, 2019-04-10
@Royamov

A 404 error should not redirect to another address, just a specific page should be displayed.
For example, https://livion.ru/1if there is no such URL, then the error page should open at this address, but not a redirect to https://livion.ru/error.

E
eratnikstudio, 2018-08-23
@eratnikstudio

Here is the whole .htaccess
# Can be commented out if causing a server error. See notes above.
Options +FollowSymLinks
# Add Cache-Control to header
Header set Connection keep-alive
Header unset ETag
FileETag None
Header set Cache-Control "max-age=2592000, public"
Header set Cache-Control "max-age=604800, public"
Header set Cache-Control "max-age=216000, private"
Header set Cache-Control "max-age=216000, public, must-revalidate"
Header set Cache-Control "max-age=1, private, must-revalidate"
# Compressing files with the gzip module
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0 [678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
# Cache files on the client
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
# Enable mod_rewrite
RewriteEngine On
# Redirect from www
RewriteCond %{HTTP_HOST} ^www.livion.ru
RewriteRule (.*) https://livion.ru/$1 [R=301,L]
# Display sitemap by short URLs
RewriteCond %{REQUEST_URI} ^(/sitemap.xml)$
RewriteRule (.*) index.php?option =com_xmap&view=xml&tmpl=component&id=1 [L]
RewriteCond %{REQUEST_URI} ^(/sitemap.html)$
RewriteRule (.*) index.php?option=com_xmap&sitemap=1 [L]
# 404 error
#
Redirect 301 example / srochnyj-notarialnyj-perevod-pasporta https://livion.ru/error
Redirect 301 /sample-data-articles/joomla/extensions/components/administrator-components https://livion.ru/error
####### ### Beginning - Rules for handling requests to block common exploits
## If you're having problems with your site, use the steps below
## They try to block the most common Joomla!
#
## Code to deny access to xml files of extensions (uncomment to activate)
#
#Order allow,deny
#Deny from all
#Satisfy all
#
## End of code to deny access to xml files
# Block any request that tries to set the value of mosConfig via URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block any request trying to corrupt base64_encode via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(. *\) [OR]
# Block any request containing the tag

N
nurjigit92, 2018-08-23
@nurjigit92

it is necessary to register in .htaccess ErrorDocument 404 /error.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question