.htaccess - Redirect Mobile User to Mobile Subdirectory While Maintaining Path Using Htaccess -
i have code works while maintaining path want:
rewriteengine on rewritecond %{http_host} !^m\.example\.com\$ rewritecond %{http_user_agent} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [nc] rewritecond %{http_cookie} !mobilecookie=true rewriterule ^(.*)$ http://m.example.com%{request_uri} [l,r=302]
but want mobile user redirected example.com/m
folder mobile site files are
right it's redirecting mobile user m.example.com
while maintaining path, want mobile user go example.com
example.com/m
while maintaining path.
can tell me add directory in code?
in order redirect subfolder, .htaccess file should like;
rewriteengine on rewritebase / # line replace "get" "got". replace get.php got.php.php. following line must either "rewriterule ^get(.*) /got.php" or "rewriterule ^get(.*) /got$1" rewriterule ^get(.*) /got.php$1 # redirecting example.com www.example.com. mobile site url http://example.com/m. so, there must control excludes mobile agents. rewritecond %{http_host} ^example.com [nc] rewritecond %{http_user_agent} !(android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile) [nc] rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc] rewritecond %{http_host} ^11.222.33.44 [nc] rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc] # remove www mobile agents. rewritecond %{http_user_agent} android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile [nc] rewritecond %{http_host} ^www.example.com$ [nc] rewriterule ^(.*)$ http://example.com/$1 [r=301,l] # add /m uri mobile agents (if hasn't added yet) rewritecond %{request_uri} !^[/]?m [nc] [or] rewritecond %{http_user_agent} android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile [nc] rewriterule ^(.*)$ http://example.com/m/$1 [qsa,l] browsermatchnocase "apache-httpclient" bots order allow,deny allow deny env=bots rewritecond %{http_user_agent} libwww-perl.* rewriterule .* – [f,l] errordocument 404 /index.php
Comments
Post a Comment