URL re-writing without affecting ajax functions - .htaccess

I am making classifieds ad web site. In that I need to load one ad without URL parameters. I did it with URL parameters successfully. Now I want to remove parameters from the URL. I stored URL-slug which is constructed saving time of ad in database. In ad page load time there are many functions called. Those functions asks data from database according to URL parameter value. I tried with htaccess rules. But rest of page and details load as before. But ajax functions called data which are supposed to display on div tags not working. They show whole page inside those divs.
I tried following htaccess rules so far.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
ReWriteRule ^ad/([a-zA-Z0-9-/]+)$ ad.php?url=$1
ReWriteRule ^ad/([a-zA-Z0-9-/]+)/ ad.php?url=$1
Now I will show sample of my function.
function load_reviews(){
var id = "<?php echo $ad->get_ad_id($unique_ad_url) ?>";
$.ajax({
url: './middle/review/load_reviews',
cache:true,
type: 'GET',
async: false,
data:{
id: id
},
success: function(response){
$('#chat_area').html(response);
},
error: function (x, e) {
if (x.status == 0) {
console.log('You are offline!! - Please Check Your Network.');
} else if (x.status == 404) {
console.log('Requested URL not found.');
} else if (x.status == 500) {
console.log('Internal Server Error.');
} else if (e == 'parsererror') {
console.log('Error. - Parsing JSON Request failed.');
} else if (e == 'timeout') {
console.log('Request Time out.');
} else {
console.log('Unknown Error. - ' + x.responseText);
}
}
});
return false;
}
In the top of ad.php file I include these code lines to grab last part of url and store it in variable.
$url=$_SERVER['REQUEST_URI'];
//echo $url;
$unique_ad_url = basename(parse_url($url, PHP_URL_PATH));
Likewise in JavaScript functions I passed ad_id to retrieve it to ajax get relevant data for current viewing ad page.
In ad list page I showed ads with their' url. That is done by as below,
<a href="ad/'.$this->url_slug($ad['AD_URL']).'" class="card all-card">
More =>
When I see network responses from chrome develop tools it shows infinitely loading same css, js, other external library files and ajax function called responses recursively. Also it added id parameter to end of ajax URLs.
In the top of ad.php file I echo $unique_ad_url to see value. It also shows inside all divs which are supposed to show only retrieved data. As I mentioned above along with whole ad page it shows that echo value.
At the end I want load ajax retrieved values to present on ad page without such problems. And URL is expected to be like,
http://ads.com/ad/daihatsu-boon-m700s-new-2016-2019-04-05-22-49-04
I appreciate your help for this issue.

Try these rule in your .htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ReWriteRule ^ad/([\w-]+)/?$ ad.php?url=$1 [L,NC,QSA]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

hey I also faced that problem. You might find help from this.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
ReWriteRule ^ad/([a-zA-Z0-9-/]+)$ ad.php?url=$1
ReWriteRule ^ad/([a-zA-Z0-9-/]+)/ ad.php?url=$1

Related

Rewrite url name using with .htaccess

I have sample website name is example.com/customer/?loc=dashboard, this website is used PHP coding. I need to change last name ?loc=dashboard to dashboard. That means I want the result website name is mydomain.com/customer/dashboard
I have added a file called .htaccess in my root folder, and add something like this, but it cannot work:
ReWriteEngine On
RewriteRule ^/dashboard /?loc=dashboard [L]
I have refer this website https://mediatemple.net/community/products/dv/204643270/.htaccess-rewrite-rules to do. But cannot work. Hope someone can guide me on how to solve this problem. Thanks.
Updated - 1
Using #RavinderSingh13 method result:
Before ?loc=dashboard result:
Updated 12/11/2021 09:19:00
Rewrite rules
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com.my/$1 [R,L]
RewriteCond %{HTTP_HOST} ^example\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com.my/$1 [R,L]
##External redirect to /customer/dashboard url rules here.
RewriteCond %{THE_REQUEST} \s/customer/?\?loc=(\S+)\s [NC]
RewriteRule ^ /customer/%1? [R=301,L]
##Internal rewrite rules to get it served by index.php file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^customer/(.*)/?$ index.php?parameter=$1 [QSA,NC,L]
Update - 2
everyoneknows.come.my/.htaccess
everyoneknows.come.my/index.php
everyoneknows.come.my/customer
everyoneknows.come.my/customer/index.php
everyoneknows.come.my/customer/account/dashboard.php
So that, in my php code, I use ?loc= replace account, then become everyoneknows.come.my/customer/?loc=dashboard
Update -3
I am using this method to get ?loc:
if (isset($_GET['loc'])) {
if (file_exists('account/' . $_GET['loc'] . '.php')) {
// if ($module_user_permission['view'] == 1) {
include_once 'account/' . $_GET['loc'] . '.php';
// } else {
// if ($_GET['loc'] != 'home') {
// include_once 'app/access_denied.php';
// } else {
// include_once 'account/dashboard.php';
// }
// }
} else {
include_once 'account/dashboard.php';
}
} else {
include_once 'account/dashboard' . (isset($_GET['system']) ? "_" . $_GET['system'] : "") . '.php';
}
With your shown attempts, samples; please try following htaccess rules file. Please make sure to clear your browser cache before testing your URLs.
Make sure your htaccess rules file is present alongside with customer folder(not inside it). In 2nd rewrite rule I have added parameter to get it pass to index.php file you can set it as per your requirement.
RewriteEngine ON
##Applying www by external redirect rules here...
RewriteCond %{HTTP_HOST} ^example\.com\.my [NC]
RewriteCond HTTPS off
RewriteRule ^(.*)/?$ https://www.example.com.my/$1 [R,L]
##External redirect to /customer/dashboard url rules here.
RewriteCond %{THE_REQUEST} \s/customer/?\?loc=(\S+)\s [NC]
RewriteRule ^ /customer/%1? [R=301,L]
##Internal rewrite rules to get it served by dashboard.php file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^customer/(.*)/?$ customer/account/dashboard.php?parameter=$1 [QSA,NC,L]

Redirect URLs with specific pattern to same URL in subsite

Update : By the help of answers, I am able to have this update. I want following expression in my .htaccess to be working . (Complete script of .htaccess is shared in question as well)
RewriteCond %{REQUEST_URI} ((mypage2(/\d{4}-\d{2}-\d{2})?/\d{1,2}) |about-us)
RewriteRule ^(.+)$ /subsite/#/$1 [R=301,NC]
Detail Of Question:
I have added angularjs subsite to an exsiting expressionengine php site.
subsite contains only three pages, which were very slow in existing website
I want htacces to redirect those three urls to new subsite urls e.g mydomain/page2/parameter1/parameter2 to mydomain/subsite/#/page2/parameter1/parameter2 and mydomain/page2/parameter1 to mydomain/subsite/#/page2/parameter1
(This is not compulsory) In subsite I want to clean up/manipulate Urls using history push state to show user
mydomain/page2/parameter1/parameter2 instaed of mydomain/subsite/#/page2/parameter1/parameter2
My .htaccess is like
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/#/$1 [L,QSA]
Following is most wanted thing to me
RewriteCond %{REQUEST_URI} ((mypage2(/\d{4}-\d{2}-\d{2})?/\d{1,2}) |about-us)
RewriteRule ^(.+)$ /subsite/#/$1 [R=301,NC] ==> when url is like mypage2(/date optional)/pagenumber then redirect it to subsite/#/mypage2(/date optional)/pagenumber
Also this is optional, I can live if following is not achieved
In my routing.js I want to manipulate urls like
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams,
fromState, fromParams, options, Data) {
var cleanUrl = window.location.toString().replace(subsite+'/#/', '');
window.history.pushState(null, null, cleanUrl);
//alert("Yes this works, it shows me the required url in browser at this moment");
//Here I am trying to clean the url
//But after that it reloads, some unwanted redirection happens after it
});
Okay, Try with below rule,
RewriteEngine On
RewriteCond %{REQUEST_URI} ^!(aSpecialString2|aSpecialString1|/)
RewriteRule ^(.+)$ /#/$1 [R=301,NC]
Here you will not get the #/uri in url but you will get %23 html entity which will respond as same as # in url and your app will work.
And I am assuming you will get the way to work it out with angular.
You can use mod_rewrite and php in the server side to this task
Create an index.php
<?php
if ( !empty($_GET['id']) ) {
$protocol = 'http://';
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
$protocol = 'https://';
}
header('Location:' . $protocol . $_SERVER["HTTP_HOST"]. '/#/' . $_GET[id]);
exit();
}
?>
You html here
Add the following in your .htaccess
RewriteEngine On
RewriteBase /
RewriteRule "index.php" - [L]
RewriteRule "^(.*)$" "index.php?id=$1"
To bypass some urls aString1,aString2 you can use:
RewriteEngine On
RewriteBase /
RewriteRule "index.php" - [L]
RewriteCond %{REQUEST_URI} !^(aString1)
RewriteCond %{REQUEST_URI} !^(aString2)
RewriteRule "^(.*)$" "index.php?id=$1"
To bypass assets you can use:
RewriteEngine On
RewriteBase /
RewriteRule "index.php" - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule "^(.*)$" "index.php?id=$1"
Now, http://example.com/s1/s2 will redirect to http://example.com/#/s1/s2
You can use mod_rewrite and javascript snippet in the client side to this task
Add the following to .htaccess
RewriteEngine On
RewriteBase /
RewriteRule "^([^?#].*)$" "/?$1" [R=301,NC]
Add following to main html
<script>
window.onload = function() {
location.hash = '/' + location.search.substr(1)
}
</script>
Now, http://example.com/s1/s2 will redirect to http://example.com/?s1/s2#/s1/s2
As your question states clearly you only need your html client routes to always have # right after domain name, here is a simple way to achieve it
As you are asking this for angular, so its very easy in that case. Just paste following code in element of index.html
<script>
var currentSitePageUrl = window.location.toString();
if(currentSitePageUrl.indexOf('#/') == -1)
{
window.location = currentSitePageUrl.replace(yourDomainUrl+'#/')
}
}
</script>
Above will include # to each url request and rest of the url will stay as it is, but only when it is requesting some front-end page
If you have access to .htaccess on your server, you can modify it to work with the URLs in your code without inserting the #.
There are really 2 parts to this, one enabling HTML5Mode in your Angularjs app and 2 editing the .htaccess file on your server to deal with this successfully.
I don't PHP at all, but was able to get this working for several sites following this article: https://ngmilk.rocks/2015/03/09/angularjs-html5-mode-or-pretty-urls-on-apache-using-htaccess/#thecode
try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} /(mypage2(/.*)|about-us) # you used mypage2, so it will be redirected to subsite/#/mypage2
RewriteRule ^(.+)$ /subsite/#/$1 [R=301,NC]
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/#/$1 [L,QSA]
notice the comment of the first rule.
and you can try your rules in sites like this: http://htaccess.mwl.be/

Redirect 404 to search page

Becouse in google webmasters I have 550.000 not found pages - 404 - I want to make some redirections to the search page.
To be userfoul for the users, need to go to the search page, but is realy complicated for me, becouse I need to EXTRACT the search phrase from the 404 url:
Here are the 2 type of url with 404 errors, and need to be redirected.
DOMAIN/movie/12298295-Iron-Man-3
DOMAIN/serie/15108-The-Walking-Dead/seasons/3/episodes/10
Of corse, I need to extract JUST THE NAME of the movie, or the serie and redirect to this url
DOMAIN/search?q=Iron-Man-3
DOMAIN/search?q=The-Walking-Dead
Well this is the URL by parts:
For "movies" just have 4 parts:
DOMAIN - of corse, is the domain name of the website
/movie/ - is created based on the content type (movie or serie)
12298295- is the ID for this item and can be form - 1 - to
infinite
Iron-Man-3 - the name of the movie (is wath I want to get)
For "series" - THE SAME like for the movies, but at the end can have more parts, and the full URL can be: (all this url, for an normal page with NO 404, are ok)
DOMAIN/serie/15108-The-Walking-Dead/seasons/3/episodes/10 - Link to episode page
DOMAIN/serie/15108-The-Walking-Dead/seasons/3/ - Link to some season page
DOMAIN/serie/15108-The-Walking-Dead/ - Link to the TOP page for this serie
Please note, I need to redirect this url, JUST if the result is an 404 page (ErrorDocument 404), becouse the same type of url are used in all pages.
Here is my actual .htacces
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php[^/] /$1? [L,R=301,NC,NE]
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php(?:/(.*))?$ /$1$2? [L,R=301,NC,NE]
RewriteCond %{QUERY_STRING} ^q= [NC]
RewriteRule ^busqueda\b /busquedas [R=301,L,QSA]
# Redirect Trailing Slashes...
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Many thanks for your help
The following shall work for both movies and series:
RewriteRule ^(?:movie|serie)/\d+-([^/]+) /search?q=$1 [R=301,L,NC]

'View Full Site' add ?m=0 to all inside pages

RewriteRule ^(.*)\.php$ ^(.*)\.php$?m=0 [R=301,L]
I want all inside pages to be rewritten to ?m=0 coming from SITEDOTCOM?m=0
So basically if someone lands comes to the full site using the trailing ? i want all the links to be ?m=0
??
REASON: Mobile redirect Full Site button works once. Does not work if user clicks on something. returns to mobile site.
my code looks like this
RewriteEngine on
RewriteBase /
# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]
# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]
# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]
# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,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} !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.Site.com%{REQUEST_URI} [R,L]
Tried top code return infinite loop.? thoughts?
This line here:
RewriteCond %{HTTP:Cookie} !\mobile=0(;|$)
should probably be checking the query string instead as well:
RewriteCond %{QUERY_STRING} !(^|&)mobile=0(&|$)
Because the cookie isn't sent to the browser until the server responds, by that time the redirect is already made. The two CO lines creates a cookie to be sent to the browser, and immediately you redirect them to mobile before there's a response.
How about something like this? Change the redirect rule to:
RewriteCond %{HTTP:Cookie} mobile=1(;|$)
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ http://m.Site.com%{REQUEST_URI}?mobile=1 [R,L]
RewriteCond %{HTTP:Cookie} \mobile=0(;|$)
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ http://Site.com%{REQUEST_URI}?mobile=0 [R,L]

Mobile redirect not working for Joomla site

I have 2 website, one regular (for desktops) and the other designed for mobile devices. They both have the same content but the mobile site is designed for phone (iphones, blackberries,etc)
Here is what I am looking for:
When the user arrives at my site on a mobile device then will be automatically redirected the mobile version. On the mobile version I have a link that says "view full html", when they click that link they will be sent to the full version of the site no matter what device they are using (desktop, iphone or whatever)
Using Litespeed webserver.
I cannot get this to work via HTACCESS. Here is what my .htacess looks like:
Options -Indexes
RewriteEngine On
RewriteBase /
#Added the rule below so that redirecting to the index.php does not operate on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR]
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST},S]
# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST},S]
# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]
# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos" [NC,OR]
RewriteCond %{HTTP:Profile} !^$
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
RewriteCond %{QUERY_STRING} !(^|&)mobile=0(&|$)
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.mysite.com [R,L]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ 404.html [F,L]
#
I try http://www.mysite.com/?mobile=1 and I an NOT sent to the mobile site.
It's a Joomla 1.0 based website and I have a SEO component installed (sh404sef), not sure its that causing a problem. The sh404sef translate url to seo friendly urls.
Can some help?
PUT THIS CODE in INDEX.PHP of your JOOMLA SITE. THIS CODE DETECTS ALMOST ALL THE MOBILES. CHANGE MOBILE.YOURSITE.COM to your desired url.
<script>
(function mobileRedirect(a,b){
if(/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))){
window.location=b;
}
})(navigator.userAgent||navigator.vendor||window.opera,'http://MOBILE.YOURSITE.COM');
</script>

Resources