views:

35

answers:

1

Hi,

I've worked-around the solution to transform all uri to one page via ErrorDocument.

The reason behind this is to send Files AND folders (nice urls) to one page. However, I need the URI string to be sent to index.php?uri=string . Is this possible via ErrorDocument, or how do I do this?

So I need to rewrite the

http://www.something.com/games/specific-game

to

http://www.something.com/index.php?uri=/games/specific-game

Is this possible at all, if, how?

+1  A: 

If your server supports server-side include (SSI) then you use the following 404.shtml as your ErrorDocument:

<html>
<header>
<meta http-equiv="Refresh" content="0; url=/index.php?uri=<!--#echo var="REQUEST_URI" -->">
</header>
</html>

EDIT: there is a simpler way: create a PHP file as your ErrorDocument and you can do anything under the sun in it! :)

EDIT2: you can access the original URI using $_SERVER['REQUEST_URI']

EDIT3: heck, if you are just redirecting to index.php on the same host, you can just set that index.php file as your ErrorDocument and detect if the request is redirected from 404 error by checking if $_SERVER['REDIRECT_STATUS'] == '404'

Lukman
yees, but .. I need to get that URI the user entered and was incorrect.. is that sent as variable to such php ErrorDocument then?
Skuta
new info: it does not work, because it's redirected to this index.php?uri=<!--#echo var= AND there is not URI in the parameter.
Skuta
meaning your server doesn't support SSI then .. just use PHP then. you can use `$_SERVER['REQUEST_URI']` to access the original URI.
Lukman