Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I put the Mobile detection in .htaccess or php?

I have a mobile version of my site working now and I want to know where should I do the redirection. I only can think to do redirection using:

  • .htaccess
  • PHP

I would like to know which one is better/more efficient? Is there a better way to do that other than in the .htaccess or PHP?

Thanks

like image 771
Tech4Wilco Avatar asked Oct 27 '11 14:10

Tech4Wilco


1 Answers

I vote for Apache.

If you do it at the Apache level (in the .htaccess file or, even better, in the Apache config), then if you have HTML files, the only way to detect this that I can think of is JavaScript; this can be easily removed (like disabling JavaScript).

This also applies to other types of files, like PDFs, Word documents, MP3 files, etc. It can easily redirect to a page that contains a "not available for mobile" message.

The other thing I can think of is a css file if they are different (standard version vs mobile version).

like image 165
Lauren Smith Avatar answered Sep 19 '22 00:09

Lauren Smith