I have htaccess file like below
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile" [NC]
RewriteCond ^ https://example.com/fernando/n-page.html [NC]
RewriteRule ^ https://example.com/fernando/error.php [R,L]
What I am looking for if n-page.html, check if the user from mobile, if from mobile redirect to error page, if from desktop, nothing to do, if other page, I do not want do anything. I am trying Mobile checking thing is working fine, just unable to check if its n-page.html or not. Let me know if anyone here can help me for solve the issue. Thanks!
CodePudding user response:
Like this instead:
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile" [NC]
RewriteRule ^fernando/n-page\.html$ /fernando/error.php [R,L]
The above states: If the request is for fernando/n-page.html
(no slash prefix) and has a mobile user-agent then redirect to /fernando/error.php
. This is a 302 (temporary) redirect.
Reference: