0

Got custom 404 and 500 error pages which don't work. I'm given the following error for both pages, when trying to access directly or via error: error img


.htaccess content:

DirectoryIndex index.php
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

ErrorDocument 404 /error_docs/404.php
ErrorDocument 500 /error_docs/500.php

error pages both contain:

<p>text</p>

I've checked both paths several times and they are correct. If i substitute the file paths for text, the text is displayed and the error works. Thanks.

brad
  • 1,407
  • 19
  • 33
  • What's your development environment? – J. Pichardo May 24 '16 at 18:03
  • Excuse my ignorance, what exactly is a DE? I'm using Chrome / Notepad++ if that helps? lol sorry, somewhat noob :D – brad May 24 '16 at 18:15
  • Basiclly, ot al the least the way I understand it, is every tool you are using to develop, in this case I wanted to know the nature of the server, but I guess you don't have access to that since you are working by ftp, Am I right? – J. Pichardo May 24 '16 at 18:22
  • The server is owned (physically) by a friend that i am in contact with. I have access to the webspace admin account. And thanks for the explanation of DE :) – brad May 24 '16 at 18:45
  • Maybe you could ask your friend to tell you what is the error happening in the logs of the server. That can give you a better idea of what is happening under the hood. – J. Pichardo May 24 '16 at 19:01
  • On it! Thanks for the help thus far :) – brad May 24 '16 at 19:03
  • are you working on a folder inside the domain or on the root. If you are working on a folder. I thing this is the issue. See my updated answer to know what to do – Kinggeov May 24 '16 at 19:23
  • @Kinggeov the RewriteBase has caused all 404s and 500s to redirect to our homepage but with broken php. I'm not sure what this is doing. Our site is currently in a subfolder named /dev/, but will be moved to the root. Should "RewriteBase /dev/" be used currently? Thanks – brad May 24 '16 at 19:50
  • Yes try that and let me know but i thing something else is wrong try i want to know the current folder structure and .htaccess rules where is the .htaccess located? Use absolute links for the 404 and 500 errors. Really it should be working. We are missing something – Kinggeov May 24 '16 at 20:42
  • @Kinggeov. .htaccess is located on the root and contains this: http://prntscr.com/b820n1 The site is located like so: `hardstyleproducers.com/hardstyleproducers.com/dev/index.php` Should the htaccess be inside the first folder? – brad May 24 '16 at 22:57
  • are error_docs inside dev folder too? .htaccess and error docs mus be inside dev folder. See my updated answer. – Kinggeov May 25 '16 at 04:20
  • @Kinggeov okay, so now the error is working from the /forum/ (mybb) subfolder, the 404 is displaying properly. It's not working from any other incorrect URL however, and is just showing the index page. try hardstyleproducers.com/dev/abc123 for example. – brad May 25 '16 at 04:47
  • See my updated answer. I figured it out – Kinggeov May 25 '16 at 09:23

2 Answers2

0

Remove this line and finally you are ready

RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Kinggeov
  • 184
  • 12
0

As an example in XAMPP whe you use ErrorDocument it redirects to the localhost folder. If I write:

ErrorDocument 404 /error_docs/404.php

It redirects to:

localhost/error_docs/404.php

In fact the ErrorDocument always redirects to the DocumentRoot

So the best way (I know right now) to do it is with an absolute path

J. Pichardo
  • 3,077
  • 21
  • 37
  • I changed the paths to absolute (http://prntscr.com/b7y5wn), and now i'm in a redirect loop. It's interesting that if i substitute the link for text, it's outputting the text (ErrorDocument is working). – brad May 24 '16 at 18:06
  • Well spotted, but actually i moved the files to the root as a friend suggested. Perhaps for the sake of this post i should have kept them, but i'm just attempting a process of elimination! :) – brad May 24 '16 at 18:10