Solving the Problem with Blogger's Custom Redirects feature on Mobile

redirect loop problem
Custom Redirects were launched in March 2012 and gave Blogger users the ability to change the permalink structure of the all types of pages on their blogs . It allows two kinds of redirects namely 301 Moved Permanently type (Which lets you pass SEO value) and 302 Moved Temporarily (Used for Coming Soon Pages or when a page is under maintenance ).  This is extremely useful for people who are migrating from other platforms , as they can now easily able to redirect pages with different permalink structure than Blogger's default to a new page. Recently there have been some issues with it , which have become a cause of frustration for many users.

What is the problem

When a Custom Redirect (example www.stylifyyourblog.com/contact ) is opened in a Mobile browser , it leads to a Redirect Loop (See Screenshot below) which doesn't allow the visitor to open the blog. This becomes a big problem when the redirect is used on the homepage of the blog (example YourBlogName.blogspot.com or a custom domain like http://www.stylifyyourblog.com/ ) which makes it impossible for the user to even visit the blog.

too many server redirects


Why this happens

The main reason for this problem occurring is the mobile parameter that Blogger adds from the server side. The m=1 parameter interferes with the custom redirect and breaks the whole functionality (As you can see in the short GIF Below). Until last year if  a custom redirect with mobile parameter was entered in a normal web browser (example stylifyyourblog.com/contact?m=1 ) it would lead to a 404 page , but this error was fixed by Blogger Team.

redirects from m=1 to non m=1 loop custom


How to Solve this Problem
As the custom Redirect feature doesn't work universally , you can always use good old JavaScript for this. Firstly I would suggest to remove the specific redirect from Settings > Search Preferences > Errors and redirections > Custom Redirects . Then go to Template > Edit HTML and search for <head> tag and add the following code just below it (Backup your template before doing this)

For example sake , I am assuming we want to redirect http://www.stylifyyourblog.com/templates to http://www.stylifyyourblog.com/search/label/Template


<script>
if(window.location.href == 'http://www.stylifyyourblog.com/templates?m=1' || window.location.href ==  'http://www.stylifyyourblog.com/templates' )
{
window.location="http://www.stylifyyourblog.com/search/label/Template";
}
</script>


As you can make out , this is just tests if the current URL is the normal or mobile version of the URL you want to redirect , if it matches then it redirects to the URL of your choice. This works in Desktop and Mobile browsers just fine ( See Youtube video below )



What is Blogger doing about it
If you want to redirect a large number of pages , then it will become unmanageable and confusing to keep adding new snippets of code to the template. This work is best done by Blogger at the Server side. As of now this issue has been escalated to the Blogger Team and they are looking into it . Hope they will fix this issue soon

If you are currently having problems with Blogger , feel free to share them in the comments , I will try to help out to my best of abilities

Written by Prayag Verma


A blogger and Web Developer currently in college learning about computers. A CSS Lover , Blogger Template Designer and Music Addict ! Get more from Prayag on and Twitter




Email Newsletter

Like what you read here in this post ?
Get new posts delivered straight to your inbox



Related Articles


Post a Comment
Rahul Roy said...

Thanks for the heads-up!

I still cannot get this to work, but maybe I'm missing something. I want my address http://www.mrachelletester2.blogspot.com to redirect to http://www.mrachelletester2.blogspot.com/p/blog-page.html

I pasted the above code under the head tag, and replaced the addresses with mine.

Am I missing something or putting it in the wrong place?
Thank you!

Prayag Verma said...

Hi McKenna Olson

I didn't take into account the ccTLD's before , try out this code

<b:if cond='data:blog.url == &quot;http://www.mrachelletester2.blogspot.com/&quot;'>
<script>
if(window.location.href == &#39;<data:blog.url/>?m=1&#39; || window.location.href == &#39;<data:blog.url/>&#39; )
{
window.location=&quot;http://www.mrachelletester2.blogspot.com/p/blog-page.html&quot;;
}
</script>
</b:if>

It's taken forever for me to reply to this, but THANK YOU a million times over!

saxeli gvari said...

THANKS SO MUCH !!!!!

Diego Villa said...

Nice fix

Helio Gomes said...

Thank you a lot!!

Jen Smith said...

Thanks for this, I've been trying to get around this for ages! :)

Jen Smith said...

ooh, I thought it worked for me, it is now showing my website on mobile view but it is also showing my blog now when I was trying to hide it i.e. I was trying to redirect www.jenmsmith.com to http://www.jenmsmith.com/p/life-coaching.html - any help appreciated!

Hi I tried using the code you gave to Mc Kena but this parts appears in red

#39;?m=1' || window.location.href == '' )

so it's not working :S! HELP

Mit Parmar said...

Thanks a lot! It really helped me.

thank you!

irfan hairi said...

hi #Prayag Verma i do as you step and paste below head, but still not change.. can u help me?.. I want my view blog in Mobile same with Desktop view when i open in android. My blog is buatkuihraya.blogspot.com i tried a lot style and various of source but still not change. When i open my blog in android my sidebar widget and header was missing, after i using code html mobile= 'yes' if have apppear but just appear in my footer side when i saw in android. I hope u can help me.. Thank you.. buatkuihraya.blogspot.com

Americana said...

Tried it a million times and it didn't work for me. :(

Bethany said...

It works! Thank you so much for this!!!

Hari said...

I recently started a new website for my business and was facing the same problem. I tried to redirect my domain http://earendilexports.com to http://www.earendilexports.com/p/welcome.html.

I've followed the technique you suggested in the above post however it's redirecting only on the desktop version of theb site and not the mobile version.

The code #39;?m=1' || window.location.href == '') appeares in red.

Please let me know how to fix it. Any help would be great

Thanks!! my problem solved when i change from default redirect that the blogger offers and use this code instead. Thanks again!!

/\/ said...

This solution works great for me - I just had a couple of issues when using this:

In my application I wanted to use the redirect to be used to point to a 'fake homepage' for my blogger, however I also wanted people to be able to view my blog as normal. To workaround this I labelled all my blogposts with an arbitrary identical label and just set up a search for that label so users could view all my blog posts with that label.

The second thing to be wary of is regarding the if statement, remember that the URL you wish to redirect from may have a "/" on the end of it even if it doesn't always show in your browsers address bar. :)

BinaRealm said...

Thanks for the help Prayag!!

Tried this for my blogger BinaRealm redirecting http://binarealm.blogspot.com/p/binarealm.html to http://binarealm.com/ and it works

But the mobile site does not show the static homepage.... A list of all my posts is shown instead.... Can I redirect mobile users to a static mobile-site homepage for my blog??

Very Good Tips Thanks a lot for sharing with us....

Rahul Das said...

It hasn't worked for me.
The page never gets loaded.

Thank you. The second version of the amended code worked for us. That's a very handy fix!

Hello, Thanks for the advice. I now understand why the problem occurs.

When I paste in the code, it works on the mobile site, but them creates a problem for the main site. It just flashes up with a '1' and creates a loop...

Any thoughts?

i tried but not solved...........................

Ketul Parmar said...

Thanks for sharing wonderful information.