I want to redirect my users to my mobile site. My mobile site is in a subfolder instead of a subdomain. Here is how I want it to work ...

Request sent to:
https://www.picturepunches.com/hot

Redirect to:
https://www.picturepunches.com/mobile/hot

I also don't want to effect the images on that page. So I want the images to be:
https://www.picturepunches.com/pictures/user/1937/19974-Theosawmon.jpg

And not:
https://www.picturepunches.com/mobile/pictures/user/1937/19974-Theosawmon.jpg

How can I do dis?

You write exceptions for certain directories. But it depends, on whether almost all links need to redirect or just the hot directory. If just the hot directory, specify that only.

Here is what I have come up with ...

RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
RewriteCond %{REQUEST_URI} !^/mobile/.*$
RewriteRule ^(.*)$ /mobile/ [L,R=302]

Can someone please edit the last 2 lines to make it work? Make sure that you read the first post.

Here is the code I currently have ...

RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteRule ^(trending|hot|featured|users|rooms|languages|comments|register|login|forgot-password|upload|contact|learn|rules|thanks)$ $1.php [NC,L]
RewriteRule ^member/(feed|subscriptions|pictures|earnings|advertise|settings|crop-picture|create-ad|create-room|manage-rooms)$ $1.php [NC,L]

RewriteRule ^mobile/(fresh|trending|hot|featured|comments|users|rooms|languages|upload|register|login|forgot-password|learn|rules|contact|thanks)$ mobile/$1.php [NC,L]
RewriteRule ^mobile/member/(feed|subscriptions|pictures|earnings|advertise)$ mobile/$1.php [NC,L]

RewriteRule ^(trending|hot|featured|users|rooms|languages|comments|register|login|forgot-password|upload|contact|learn|rules|thanks)$ mobile/$1 [L,R=301]

Sorry to say this, but user agent sniffing was/is never a good strategy. Just make your site mobile friendly, so you don't have to alter/update multiple code bases and your URLs work everywhere!

XKCD covers this as well -> https://xkcd.com/869/

Make it mobile friendly and avoid making versions for desktop, mobile, iPads and such. You'll go mad trying to keep it in sync and working.

Using htaccess for mobile detection and subfolder redirection is a primitive way. You can as rrproffitt suggested first try to built a responsive web app and then when you will see that this is not a good way do it as big companies do (google, facebook, twitter , name it … ) “first adjustive and then responsive”. That means to detect the device inside your web app. Have two (desktop/mobi) or three (desktop/mobi/tablet) versions for css and content part and serve the same logical units in the same url's.

I already worked on this project. I might take your advice later but for now can anyone help?

Hey guys, I have found the solution to my problem ...

With htaccess redirect you need to specify the full url of the destination redirct. This is what I did ...

RewriteCond %{REQUEST_URI} !^/mobile/.*$
RewriteRule ^(fresh|trending|hot|featured|users|rooms|languages|comments|register|login)$ https://www.picturepunches.com/mobile/$1 [L,R=302]
RewriteEngine on
RewriteBase /

# Check if this is the noredirect query string
   RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
   # Set a cookie, and skip the next rule
    RewriteRule ^ - [CO=mredir:0:www.example.com]
    RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
    RewriteCond %{HTTP:Profile}       !^$ [OR]
        RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)
   # Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE}        !^.*mredir=0.*$ [NC]
# Now redirect to the mobile site
RewriteRule ^ http://m.example.com [R,L]