I have a site that stores an index.php
for desktop computers and a mobile.php
for mobile devices. Both files are in the same directory (say /var/www
). As default the user accesses index.php
and if his screen width is less than 900 px he gets redirected to mobile.php
.
To load various content within index.php
or mobile.php
there are menu links passing one or two php variables which state the directory where the content is stored.
for example, if I want to display the location I load the page from ./Contact/Location/Location.php
into index.php
.
The problem is here that .htaccess
does not know if I'm working with the default or with the mobile site, so the following rules do not work together:
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$ index.php?id=$1&id2=$2 [QSA]
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$ mobile.php?id=$1&id2=$2 [QSA,L]
Is there a way to make it working? The main advantage of having it like this is that I don't have to maintain two sites. The layout is made entirely within mobile.php
and index.php
.
/1234/5678/
for desktop and/m/1234/5678/
for mobile? You say that users are getting redirect do mobile, so then it would just be a matter of changing the code that does the redirect to use the/m/
URLs.