0

This is my .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?url=$1 [NC,L]

ErrorDocument 100 http://localhost/user/error
ErrorDocument 101 http://localhost/user/error
ErrorDocument 200 http://localhost/user/error
ErrorDocument 201 http://localhost/user/error
ErrorDocument 202 http://localhost/user/error
ErrorDocument 203 http://localhost/user/error
ErrorDocument 204 http://localhost/user/error
ErrorDocument 205 http://localhost/user/error
ErrorDocument 206 http://localhost/user/error
ErrorDocument 300 http://localhost/user/error
ErrorDocument 301 http://localhost/user/error
ErrorDocument 302 http://localhost/user/error
ErrorDocument 303 http://localhost/user/error
ErrorDocument 304 http://localhost/user/error
ErrorDocument 305 http://localhost/user/error
ErrorDocument 307 http://localhost/user/error
ErrorDocument 400 http://localhost/user/error
ErrorDocument 401 http://localhost/user/error
ErrorDocument 402 http://localhost/user/error
ErrorDocument 403 http://localhost/user/error
ErrorDocument 404 http://localhost/user/error
ErrorDocument 405 http://localhost/user/error
ErrorDocument 406 http://localhost/user/error
ErrorDocument 407 http://localhost/user/error
ErrorDocument 408 http://localhost/user/error
ErrorDocument 409 http://localhost/user/error
ErrorDocument 410 http://localhost/user/error
ErrorDocument 411 http://localhost/user/error
ErrorDocument 412 http://localhost/user/error
ErrorDocument 413 http://localhost/user/error
ErrorDocument 414 http://localhost/user/error
ErrorDocument 415 http://localhost/user/error
ErrorDocument 416 http://localhost/user/error
ErrorDocument 417 http://localhost/user/error
ErrorDocument 500 http://localhost/user/error
ErrorDocument 501 http://localhost/user/error
ErrorDocument 502 http://localhost/user/error
ErrorDocument 503 http://localhost/user/error
ErrorDocument 504 http://localhost/user/error
ErrorDocument 505 http://localhost/user/error

if I enter: http://localhost/usuarios/ everything is perfect, but when I enter http://localhost/usuarios shows me the error page because I remove the /

When I remove the absolute path leaving ErrorDocument 404 /error i do not fault in any way, the problem is that i do not recognize the file error.tpl error without absolute path because this index is called to another folder.

Questions:

  1. Is there any way to save write 40 times ErrorDocument xxx http://localhost/user/error.
  2. I want to avoid getting and modify the route when climbing the project to the real server. That's why I would like to NOT use the full path.
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
GePraxa
  • 67
  • 1
  • 17
  • 1
    What exactly are you trying to do? Why would you include an `ErrorDocument` configuration for [HTTP codes in the 200 (Success) range](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success)? – ChrisGPT was on strike Sep 05 '16 at 17:36
  • @Chris Good is just one example of all pages that could be set up, you do not want to use all Desir. The main problem is to solve the two questions, the second want to know if there is a way to avoid putting the same URL many times (does not mean you use all), I want to know if you can define variables within the file or as a professional would save write the same in many lines. – GePraxa Sep 05 '16 at 17:40
  • 1
    It would be correct to show only error page for states 4xx and 5xx or I'm wrong? – GePraxa Sep 05 '16 at 17:44

1 Answers1

1
  1. I'm not aware of any way to have one directive apply to multiple status codes. This answer also says that it's not possible.

  2. You can use local URLs as shown in the documentation (bold mine):

    The syntax of the ErrorDocument directive is:

    ErrorDocument <3-digit-code> <action>
    

    where the action will be treated as:

    1. A local URL to redirect to (if the action begins with a "/").
    2. An external URL to redirect to (if the action is a valid URL).
    3. Text to be displayed (if none of the above). The text must be wrapped in quotes (") if it consists of more than one word.

    The following example is also given:

    ErrorDocument 500 /cgi-bin/crash-recover
    

Finally, you ask in a comment

It would be correct to show only error page for states 4xx and 5xx or I'm wrong?

That's correct. That same page of documentation says

Customized error responses can be defined for any HTTP status code designated as an error condition - that is, any 4xx or 5xx status.

Community
  • 1
  • 1
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257