I have a PHP website about books that uses URL Rewriting rules already defined on my .htaccess file on my Apache Server, so due to the following rule I already have URLs like
http://www.example.com/book/name-of-book.html
RewriteRule ^book/([^/]+)\.html$ book.php?book=$1 [QSA,L]
I want to improve my website and make a mobile version of it and I want to use URLs such as
http://m.example.com/book/name-of-book.html
As I am not completely done with mobile development I want only the book section to have a mobile version. So http://www.example.com would remain the same, but http://www.example.com/book/… would trigger the condition.
Which rules should I append to my .htaccess file?
Try using this:
These horrible conditions in the first two lines will detect the mobile browsers by their User-Agent headers. The following rule will redirect queries to the mobile site.
The fourth line is needed to rewrite the paths for devices that are not moblie devices.