Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect user to mobile site and back in typo3 with typoscript

I have found that if I use the below typoscript I can redirect my users to the mobile version of the site which has its own tree in the backend of my typo3 site.

[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]
config.additionalHeaders = Location: http://m.example.com/
[end]

It is a simplified version of the site however so I want to have a return to full website link. But due to my above typoscript redirecting users to the m domain i can't get back to www.example.com.

Does anyone have any typoscript suggestions here?

like image 955
ak85 Avatar asked Dec 01 '25 14:12

ak85


1 Answers

You need an additional parameter in your link back which you can use to turn off the redirection.

Try something like this:

# check for mobile browser
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]
config.additionalHeaders = Location: http://m.example.com/
[global]

# undo mobile redirect if mobile param is set
[globalVar = GP:nomobileredirect > 0]
config.additionalHeaders =
[global]

and redirect to http://www.example.com/?nomobileredirect=1 on your link back.

To keep a nomobileredirect-value in all generated links, add nomobileredirect to your linkVars, e.g.

config.linkVars = nomobileredirect,L
like image 133
adhominem Avatar answered Dec 04 '25 18:12

adhominem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!