Redirects errors 400, 401, 403, 404, 500 htacces

0

I have the following htaccess:

# Inicio No Cache

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header unset Last-Modified
</FilesMatch>
#2 hours
<FilesMatch "\.(html|htm|xml|txt|xsl|php)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header unset Last-Modified
</FilesMatch>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header unset Last-Modified
</FilesMatch>

# Fin No Cache

# Inicio No Navegar Entre Carpetas

Options All -Indexes

# Fin No Navegar Entre Carpetas

# Inicio Url Amigable

RewriteEngine On
RewriteRule ^(\w+)$ index.php?action=$1

# Fin Url Amigable

# Inicio Redireccionar

ErrorDocument 400 http://localhost:8080/checkLogin/
ErrorDocument 401 http://localhost:8080/checkLogin/
ErrorDocument 403 http://localhost:8080/checkLogin/
ErrorDocument 404 http://localhost:8080/checkLogin/
ErrorDocument 500 http://localhost:8080/checkLogin/

# Fin Redireccionar

Error 404 redirects Ok, others do not, for example: The 403 when I put the following URL: link : it takes me directly to the error by default giving me access to the localhost .

On the other hand I also have to filter the url but it happens the same:

class EnlacesPaginas{
    public function enlacesPaginasModel($enlacesModel){
        if ($enlacesModel == "nuevoDepartamento" 
            || $enlacesModel == "nuevoCuenta"
            || $enlacesModel == "nuevoSite"
            || $enlacesModel == "inicio") 
        {
            $module = "views/modules/crudAbmUsuariosTablas/".$enlacesModel.".php";
        }
        else if($enlacesModel == "index"){
            $module = "views/modules/crudAbmUsuariosTablas/inicio.php";
        }
        else{
            $module = "views/modules/crudAbmUsuariosTablas/inicio.php";
        }
        return $module;
    }
}

How can I make any errors redirect me to start? Or that I have configured erroneously?

    
asked by Juan 08.05.2018 в 17:49
source

1 answer

0

You should specify the destination pages in your .htaccess in this way:

ErrorDocument 404 /errors/404.php
ErrorDocument 403 /errors/403.php

This way you are indicating the path to the page that should show the error.

If you want all the errors to redirect you to the main page of your site, it will be enough to put all of them in the same address.

ErrorDocument 404 /inicio.php
ErrorDocument 403 /inicio.php
    
answered by 08.05.2018 в 20:25