1

I've added this code in my .htaccess

i dont want to redirect /img/ folder... other all directorys want to redirect mobile site like this htaccess code.. plz give me to code for this one.. thanks

I have all of the images in the http://www.exemple.com/img/ folder.

When I try to load those images from my mobile, the path seems wrong because of that redirection and even if I call the image with the full path, it's not working.

/.htaccess

RewriteEngine On
RewriteBase /

#http://stackoverflow.com/questions/3680463/mobile-redirect-using-htaccess
# Check if m=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)m=1(&|$)
RewriteRule ^ - [CO=m:1:%{HTTP_HOST}]

# Check if m=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
RewriteRule ^ - [CO=m:0:%{HTTP_HOST}]

# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
RewriteRule ^ - [S=1]

# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$
RewriteCond %{QUERY_STRING} !^m=0(?:&|$)
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie}        !\m=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.col3negmovie.com%{REQUEST_URI} [R,L]

# Go back to full site
RewriteCond %{HTTP_HOST} ^m\.
RewriteCond %{QUERY_STRING} (?:^|&)m=0(?:&|$)
RewriteRule ^ http://col3negmovie.com%{REQUEST_URI} [R,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [NC,L]

RewriteRule ^.*$ index.php [NC,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
user3501407
  • 447
  • 6
  • 21

1 Answers1

1

Add this new rule for handling images just below RewriteBase line:

RewriteRule ^img(/.*)?$ - [L,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643