title: Redirect to mobile pages with different filename extension using .htaccess
body: <p>I have created a desktop website at www.domain.com and a mobile site at m.domain.com., and am redirecting smartphone visitors to the latter using .htaccess:</p>
  
  <pre><code># Mobile redirect #
  RewriteEngine on
  RewriteBase /
  
  # prevent looping
  RewriteCond %{HTTP_HOST} !^m.goldenhinde.com$
  
  # if the browser accepts these mime-types, it's definitely mobile, or pretending to be
  RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
  
  # a bunch of user agent tests
  RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
  RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
  
  RewriteCond %{HTTP_REFERER} !^http://(.*).goldenhinde.com/.*$ [NC]
  
  # rewrite rules here
  RewriteRule .? http://m.goldenhinde.com%{REQUEST_URI}  [L,R=302]
  </code></pre>
  
  <p>However, the problem I have is that URLs for pages on my desktop site do not feature a filename extension (<em>e.g.</em> www.website.com/contact), whereas those on the mobile site have the .php suffix (<em>e.g.</em> m.website.com/contact.<strong>php</strong>).</p>
  
  <p>When visitors enter an address such as www.website.com/contact on their smartphones, I would like them to be redirected to m.website.com/contact.php, but this is obviously not occurring at present due to the inclusion of the filename extension in the mobile version.</p>
  
  <p>Can you advise what code I can add to my .htaccess file so the desktop pages automatically redirect to their mobile equivalent.</p>
  
  <p>Thanks in advance for any help you can provide.</p>