Indexhibit
Index + Exhibit

Login:

Created by
Daniel Eatock
Jeffery Vaska
And You

Customizing error 404

 

Indexhibit version: 2.0
Thread is resolved.

luquerias
SPAIN
2 year(s) ago
Permalink Post

Hi, i have tried to set the 404 error by .htaccess but it wasn't working properly.

  1. When the URL was something like magentatarrega.com/… but when it was something like magentatarrega.com/index.php/album-1/subalbum-b/ (a old exhibit i created 2 weeks ago) it was not working, redirecting me to a normal 404 error message.
  2. This was my .htaccess:
  3. RewriteEngine on 
  4. RewriteCond %{REQUEST_FILENAME} -f [OR]
  5. RewriteCond %{REQUEST_FILENAME} -d
  6. RewriteRule ^(.+) - [PT,L]
  7. #RewriteRule ^(.+) index.php
  8. ErrorDocument 404 magentatarrega.com
  1. So, as it was not working i asked my hosting (dreamhost) what to do, and they give me a solution that may be will give me problems in the future. The solution was to edit index.php file and write
  2. header("Location: magentatarrega.com";);
  3. instead of
  4. front_error('File Not Found', 404);

Is this a proper way to a 404 error redirection? It works, but i'm not sure it will always work... what do you think? thanks!

luquerias
SPAIN
2 year(s) ago
Permalink Post

Sorry for the code wrapping... by the way i did other site: dhosphotography.com

And it is strange, because it redirects you to home when you type a non-existent url... but it keeps the url on the browser...

luquerias
SPAIN
2 year(s) ago
Permalink Post

Sorry for posting so much, it's just to say that now .htaccess file seems to be working. I've used same code:

  1. RewriteCond %{REQUEST_FILENAME} -f [OR]
  2. RewriteCond %{REQUEST_FILENAME} -d
  3. RewriteRule ^(.+) - [PT,L]
  4. #RewriteRule ^(.+) index.php
  5. ErrorDocument 404 magentatarrega.com

it's is so strange than before it was not working and now it works... thanks!

luquerias
SPAIN
2 year(s) ago
Permalink Post

No, it's not working... i'm coming back to

  1. header("Location: magentatarrega.com";);
  2. instead of
  3. front_error('File Not Found', 404);

Is this a proper way? thanks!

luquerias
SPAIN
2 year(s) ago
Permalink Post

Hi! Anybody can tell me if it is a proper way to edit index.php to redirect to url when error 404 happens? thanks!

luquerias
SPAIN
2 year(s) ago
Permalink Post

great, thanks... you just don't want to answer my question...ok, i get it.

Best Answer!
Vaska A
UNITED STATES
2 year(s) ago
Permalink Post

I thought it had been answered...I don't see every thread in here anymore (well, not every day).

We have not setup anything special for error pages - yet. It's a planned addition but right now we have some more important bugs and issues to work on.

The way it works now is that it will show your main page but it does alert Google with a header that that particular page is not found. If you don't want that, you could jumpstart things...

In the index.php file you are looking at above move lines 112-114 to the beginning of the sequence at line 95 - it will end up looking like this:

  1.     if (!$OBJ->vars->exhibit) 
  2.     {
  3.         // we don't search engines indexing this
  4.         front_error('File Not Found', 404);
  5.         exit;

Now, you can customize the template for errors which can be found at /ndxzsite/error.php.

luquerias
SPAIN
2 year(s) ago
Permalink Post

First of all... sorry for my umpleasant words... i have tried it but it doesn't seem to work... anyway, i'll try again this evening and see what happens.. thanks again.

Vaska A
UNITED STATES
2 year(s) ago
Permalink Post

It will work...works great for me... ;)

luquerias
SPAIN
2 year(s) ago
Permalink Post

Is not working...i don't know why. I even spoke with a dreamhost technician, he was great helping me, but none of us made it worked... i will wait for upcoming versions to do it... :)

Vaska A
UNITED STATES
2 year(s) ago
Permalink Post

Why would you ask him for help? They aren't going to help with that...

If you placed the code at the right line, it will work - it's a very simple change. Show us what you have done...

ncott
UNITED STATES
2 year(s) ago
Permalink Post

Actually, I'm having trouble with it as well - I'm getting an error 500 page. My code, from line 93 to 117:

    if (!$OBJ->vars->exhibit)
    {
            // we don't search engines indexing this
            front_error('File Not Found', 404);
            exit;

        // try again with site root - the 'home' page
        $OBJ->vars->exhibit = $OBJ->db->fetchRecord("SELECT *
            FROM ".PX."objects, ".PX."objects_prefs, ".PX."sections
            INNER JOIN ".PX."settings ON adm_id = '1'
            WHERE home = '1'
            AND status = '1'
            AND section_id = secid
            AND object = obj_ref_type");
            
        // we don't cache these
        $CACHE->defaults['caching'] = false;
        
        header("HTTP/1.1 404 Not Found");

        // we need a formal error page
        if (!$OBJ->vars->exhibit)
        {
        }
    }

luquerias
SPAIN
2 year(s) ago
Permalink Post

I asked him why it wasn't working my .htaccess file 404 redirection and he kindly did some changes for me in the index.php to try make it working.... and he is still interested in this, last mail he told me to inform him about anything new... really nice agent.

Anyway, i did the changes you said Vaska, and it doesn't seem to be working:

Test 404

My lines from 93 to 117:

  1. if (!$OBJ->vars->exhibit) 
  2.     {
  3.         // we don't search engines indexing this
  4.             front_error('File Not Found', 404);
  5.             exit;
  6.         // try again with site root - the 'home' page
  7.         
  8.         $OBJ->vars->exhibit = $OBJ->db->fetchRecord("SELECT * 
  9.             FROM ".PX."objects, ".PX."objects_prefs, ".PX."sections 
  10.             INNER JOIN ".PX."settings ON adm_id = '1' 
  11.             WHERE home = '1'
  12.             AND status = '1' 
  13.             AND section_id = secid 
  14.             AND object = obj_ref_type");
  15.             
  16.         // we don't cache these
  17.         $CACHE->defaults['caching'] = false;
  18.         
  19.         header("HTTP/1.1 404 Not Found");

        // we need a formal error page
        if (!$OBJ->vars->exhibit)
        {
            
        }
    }

Thanks!

Showing 1 - 13 of 13 posts in Forum » Customize » Customizing error 404
 

This thread has been closed, thank you.