php - m.example.com won't redirect properly -


i trying make pretty urls mobile site. have working site desktop, , give user option enter mobile version.

i have php file called mobile.php in same dir index.php. parameters of sites same. parameters desktop version working fine, but. if enter m.example.com go desktop version, if enter m.example.com/something go mobile version.

    # changing www nonwww rewriteengine on rewritebase / rewritecond %{http_host} ^www\.(.*)$ [nc] rewriterule ^(.*)$ http://%1/$1 [r=301,l]  #redirect mobile site rewritecond %{http_host} ^m.example.com rewritecond %{request_filename} !-f rewritecond %{request_uri}  ^/([^/]+)/?([^/]*)?/?([^/]*)?/?([^/]*)?/?   [nc] rewriterule ^(.*)$ mobile.php?site=%1&brand=%2&model=%3&repid=%4 [l]    #redirect dekstop. rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri}  ^/([^/]+)/?([^/]*)?/?([^/]*)?/?([^/]*)?/?   [nc] rewriterule .*    index.php?site=%1&brand=%2&model=%3&repid=%4  [l] 

furthermore. when @ mobile site, try link resources src="/image.png". on desktop work fine, mobilesite make url file m.example.com/image.png , can't find resources. bypassed entering whole url, use other way.

i hope 1 can me out on ;)

looks culprit second rule doesn't match landing page uri /, try this:

rewriteengine on rewritebase / rewritecond %{http_host} ^www\.(.+)$ [nc] rewriterule ^(.*)$ http://%1/$1 [r=301,l]  #redirect mobile site rewritecond %{http_host} =m.example.com rewriterule ^/?$ mobile.php [l]  rewritecond %{http_host} =m.example.com rewritecond %{request_filename} !-f rewriterule ^([^/]+)/?([^/]*)?/?([^/]*)?/?([^/]*)?/? mobile.php?site=$1&brand=$2&model=$3&repid=$4 [l,qsa]  #redirect dekstop. rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/?([^/]*)?/?([^/]*)?/?([^/]*)?/?  index.php?site=$1&brand=$2&model=$3&repid=$4 [l,qsa] 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -