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>

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.