Sir, my website's mobile version is www.m.example.com
I put the code of mobile site in folder named mobile
.Now I want to redirect the mobile users to www.m.example.com.
I put some code in htacces file and checked using mobile. Then www.example.com correctly redirected to www.m.example.com. But a problem found. The problem is that, when checked url with get variable like, www.example.com/listing/category/ct-12
etc, it is redirected to only www.m.example.com
. not to www.m.example.com/listing/category/ct-12
. Anyone help me for correct htacces code..
My website is using PHP
This is My htacces code in public html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
RewriteRule ^(.*)/(.*)/(.*)/([0-9]+)$ listing/list-name.php?State=$1&Location=$2&Name=$3&Id=$4 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ct-([0-9]+)/page-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Loc=$3&Category=$4&CId=$5&start_page=$6 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/ct-([0-9]+)/page-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Category=$3&CId=$4&start_page=$5 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ct-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Loc=$3&Category=$4&CId=$5 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/ct-([0-9]+)/page-([0-9]+)$ listing/list.php?State=$1&Category=$2&CId=$3&start_page=$4 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/ct-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Category=$3&CId=$4 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/ct-([0-9]+)$ listing/list.php?State=$1&Category=$2&CId=$3 [L,NC,QSA]
RewriteRule ^http://www.example.com index.php
Options -Indexes
This is my htacces in folder named listing
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Options -Indexes
My final htacces
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)noredirect=true(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]
# Check if this looks like a mobile device
# (You could add another [OR] to the second one and add in what you
# had to check, but I believe most mobile devices should send at
# least one of these headers)
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile} !^$
# 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} !\smredir=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://www.m.example.com%{REQUEST_URI} [R,L]
RewriteRule ^(.*)/(.*)/(.*)/([0-9]+)$ listing/list-name.php?State=$1&Location=$2&Name=$3&Id=$4 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ct-([0-9]+)/page-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Loc=$3&Category=$4&CId=$5&start_page=$6 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/ct-([0-9]+)/page-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Category=$3&CId=$4&start_page=$5 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/ct-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Loc=$3&Category=$4&CId=$5 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/ct-([0-9]+)/page-([0-9]+)$ listing/list.php?State=$1&Category=$2&CId=$3&start_page=$4 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/(.*)/ct-([0-9]+)$ listing/list.php?State=$1&Dis=$2&Category=$3&CId=$4 [L,NC,QSA]
RewriteRule ^(.*)/(.*)/ct-([0-9]+)$ listing/list.php?State=$1&Category=$2&CId=$3 [L,NC,QSA]
RewriteRule ^http://www.example.com index.php
Options -Indexes