Reputation: 6069
I have a book PHP website 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/livro/name-of-book.html
RewriteRule ^livro/([^/]+)\.html$ livro.php?livro=$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/livro/name-of-book.html
Which rules should I append to my .htaccess file?
Upvotes: 1
Views: 1283
Reputation: 143876
Before the rules that you have, add this:
RewriteCond %{HTTP_HOST} !^m.example.com$ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteRule ^(.*)$ http://m.example.com/$1 [L,R=302]
Upvotes: 1