내 웹 사이트 모바일 버전은 www.m.example.com
입니다. mobile
이라는 폴더에 모바일 사이트 코드를 넣습니다. 이제 모바일 사용자를 www.m.example.com으로 리디렉션하고 싶습니다. htacces 파일에 코드를 입력하고 모바일을 사용하여 확인했습니다. 그런 다음 www.example.com을 www.m.example.com으로 올바르게 리디렉션했습니다. 그러나 문제가 발견되었습니다. 문제는 www.example.com/listing/category/ct-12
등의 get 변수로 URL을 검사하면 www.m.example.com
으로 리디렉션된다는 것입니다. www.m.example.com/listing/category/ct-12
이 아닙니다. 누구나 .. 내 웹 사이트는이 폴더 내 htacces이htacces를 사용하여 모바일 버전으로 URL을 리디렉션하는 방법
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Options -Indexes
listing
라는
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
공공 HTML에서 내 htacces 코드 PHP
을 사용하고 올바른 htacces 코드를 도와 내 최종 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
제공하여'.htaccess' 내용 –
가능한 우리 만 재보고 후 조사 할 수 있습니다 중복 http://stackoverflow.com/questions/3680463/mobile-redirect-using-htaccess –
규칙. – anubhava