简体   繁体   中英

Redirect mobile users to a url specific via Htaccess

I have this code in my .htaccess (default of my PHP site) and would like to redirect my users when accessing by cell, for a specific URL.

 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L] RewriteCond %{HTTP_ACCEPT} "text\\/vnd\\.wap\\.wml|application\\/vnd\\.wap\\.xhtml\\+xml" [NC] RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^ http://pipocaplayfm.com/new-releases%{REQUEST_URI} [R,L] </IfModule>

Try this one.

RewriteEngine On
# Check for mime types commonly accepted by mobile devices
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ http://m.domain.com%{REQUEST_URI} [R,L]

for more info check this topic.

http://www.inmotionhosting.com/support/website/redirects/mobile-redirect

Or check this answer for php code to do this.

https://stackoverflow.com/a/13109951/7387742

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM