balexander
balexander

Reputation: 24389

.htaccess or JavaScript Redirecting

I have a mobile site at m.site.org and the main site at site.org I am using htaccess to redirect other pages but not sure if it's useful in this case.

If people are on a mobile phone and they go to the main site I want them to be redirected to the mobile version. Once on the mobile version we have an option to go back to the full site so I don't want them stuck in a redirect loop and can't go to the main desktop version.

I can not use server-side code and would like to know if there were an option without JavaScript (doubtful).

EDIT:

The link site.org I would like redirected but NOT site.org/index.html through htaccess. Possible? Does this help?

Upvotes: 1

Views: 820

Answers (2)

NG.
NG.

Reputation: 22914

You should check this out. It provides regular expressions you use against the user-agent that can be done client side, and it is open source.

You can download an htaccess or get JS from it. Then edit at will. The htaccess gives you a rewrite cond. JS will give you a function.

Now this won't scale if a new phone comes to the market, but it's pretty decent and you can change it as new things come. Or you can run a process that fetches and deploys the new regular expressions periodically

Upvotes: 1

Lekensteyn
Lekensteyn

Reputation: 66465

Without touching the server, or adding JS, it's going to be difficult.

If you can check for the HTTP_USER_AGENT header on your server, you could display a HTML redirect:

<meta http-equiv="Refresh" content="0;URL=http://m.site.org" />

Upvotes: 0

Related Questions