0

I created a mobile application available using the following link :

www.mysite.com/mobile.php

my issue is to detect the mobile version when I use the link of the site www.mysite.com and redirect me using htaccess to the link of my mobile application www.mysite.com/mobile.php.

I notice that the application is developed with Symfony1.4

In all layouts of my mobile application I use this html code in the top :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

Edit :

here is my htaccess after modification :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]
RewriteRule ^(.*) $1? [L]
</IfModule>

 Options +FollowSymLinks +ExecCGI

 <IfModule mod_rewrite.c>
 RewriteEngine On

 # uncomment the following line, if you are having trouble
 # getting no_script_name to work
 RewriteBase /

 # we skip all files with .something
 #RewriteCond %{REQUEST_URI} \..+$
 #RewriteCond %{REQUEST_URI} !\.html$
 #RewriteRule .* - [L]

 # we check if the .html version is here (caching)
 RewriteRule ^$ index.html [QSA]
 RewriteRule ^([^.]+)$ $1.html [QSA]
 RewriteCond %{REQUEST_FILENAME} !-f

 # no, so we redirect to our front web controller
 RewriteRule ^(.*)$ index.php [QSA,L]

 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} iphone|ipad|android|blackberry [NC]
 RewriteRule ^$ /mobile.php

 </IfModule>

But it dosn't work!

I don't hope something very defficult,I wish change the htaccess above to have that scenario:

I access to the link www.mysite.com(the same link in 2 cases ) :

1- to see my principal site, htaccess point on the front controller index.php by default.

2- If I visit the mobile version, htaccess will detect it and point me on the front controller mobile.php to redirect me directly to app mobile.

Nll
  • 819
  • 5
  • 19
  • 41

1 Answers1

1

You can detect mobile devices with a RewriteCond %{HTTP_USER_AGENT}

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iphone|ipad|android|blackberry [NC]
RewriteRule ^$ /mobile.php
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198