Q:

Apache rewrite hostname on 404

I have two versions of my website: a full site for desktop browsers, and a mobile site which contains mobile-friendly versions of some of the pages from the desktop site. The urls for both sites are identical when viewed from outside, an internal device recognition layer sends users to one site or the other depending on the User Agent.
I would like to configure Apache to detect when someone tries to access a page on the mobile site which does not exist, and forward them on to the same page on the desktop site. Some rule like this is what I have in mind, is it possible?
ErrorDocument 404 http://<ip of desktop site>/<request url without hostname>

A:

Using mod_rewrite to foward requests that don't correspond to an existing file or directory 
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

For further information you can look at: www.phpriot.com

