andre
andre

Reputation: 329

Error 404 page and htaccess issues

What is going on is the following: I have a client which requested me to created a custom 404 error page (for SEO purposes), here follows his website:

http://www.proloterica.com.br (site)

http://www.proloterica.com.br/erros/404.html (404 path working)

http://www.proloterica.com.br/contato/cont (trying to reproduce the 404 error, nothing happens)

http://www.proloterica.com.br/cont (Error 500 happening):

Internal Server Error: The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Here follows the htaccess file:

AddDefaultCharset ISO-8859-1

SetEnv SESSAO "SITE"

Options -Indexes

#Habilita o Módulo de Reescrita
RewriteEngine On

#Se a URL apontar para um arquivo, vai diretamente para ele
RewriteCond %{REQUEST_FILENAME} !-f
#Se a URL apontar para uma pasta, vai diretamente para ela
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?(.*)$ $1/index.php?id=$2&pg=$3&sub=$4&aux1=$5&aux2=$6&aux3=$7&aux4=$8

#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

ErrorDocument 404 /erros/404.html

Any Idea how to solve this issue?

The error page 404 works if I remove the following:

RewriteRule ^([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?(.*)$ $1/index.php?id=$2&pg=$3&sub=$4&aux1=$5&aux2=$6&aux3=$7&aux4=$8

Upvotes: 1

Views: 132

Answers (1)

Sergio Ivanuzzo
Sergio Ivanuzzo

Reputation: 1922

First, most likely, you have this error because you haven't set flag [L]. So, replace:

RewriteRule ^([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?(.*)$ $1/index.php?id=$2&pg=$3&sub=$4&aux1=$5&aux2=$6&aux3=$7&aux4=$8

with:

RewriteRule ^([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?(.*)$ $1/index.php?id=$2&pg=$3&sub=$4&aux1=$5&aux2=$6&aux3=$7&aux4=$8 [L]

(I've added [L] to the end of this string).

And notice, that only one string under RewriteCond will be executed. So, when you removed RewriteRule you get your ErrorDocument working.

Upvotes: 1

Related Questions