Forum Moderators: coopster

Message Too Old, No Replies

Custom 404 Handling

         

nrobidoux

7:25 am on Jan 20, 2008 (gmt 0)

10+ Year Member



My project that I'm working on is basically an online web-mall. I've done gobs and gobs of coding and have hit a stumbling block. There's the potential for A LOT of repetitive code and content.... because each store basically uses the same backend. So I've done a lot of work trying to eliminate that.

One of my thoughts is this. A single user might have multiple stores. Each using the same privacy policy, TOU, etc. As a convenience to the user for maintainence I wanted to somehow have one copy of the content and "paste" it with a require() call.

I was hoping to do this with server variables but it isn't working as intended. This is what is happening:

I click on the privacy.php.
A 404 error is generated and goes to my custom page.
There is no reference to privacy.php in any of the variables (but the 404 custom page), hence my script crashes at this point (not literally but I'm unsure what to do).

What I thought would happen is:

-404 generated, goes to my custom page.
-I parse out out REQUEST_URI (or some variable) the intended page the user wanted to goto.
-I redirect to another file... one whose purpose is to find these shared content pages (i.e. privacy.php)
-This file checks a subdirectory created for this user for the file.
-The files checks a site-wide subdirectory for this file
-The file then redirects to the 404 page (really thats the secondary purpose, primary is to act as a template for the store) returns either the path to the content or 404 and a flag so there wont be an infinite redirect

All the code is in place except I don't know where I can find the page the user originally wanted. Can this be done?

nrobidoux

7:57 am on Jan 20, 2008 (gmt 0)

10+ Year Member



I found the answer to my problems. Thanks evryone.

I had to put a .htaccess file in my directory. For some reason thought the GUI interface provided by my hosting company would provide the same behavior. It doesn't.... w/.htaccess the REQUEST_URI is set to the value I was expecting not the custom 404 page.

coopster

5:40 pm on Jan 21, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You got it. Good work, nrobidoux and welcome to WebmasterWorld.