The same users clicking on i.e. www.thealexandertechnique.co.uk/costs.html don’t get redirected. This is driving me nuts and I’ve tried what seems like a zillion suggestions from different websites.
This is the relevant bit of my current .htaccess file. I can post the whole thing if it helps.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.thealexandertechnique\.co\.uk\.*$
RewriteRule ^ https://www.mobile.thealexandertechnique.co.uk
Any and all suggestions and explanations gratefully received.
And, yes I know I should be making the main site responsive however, I have also being trying and failing with that too. The sidebar really screws things up.
Once I can get the above working if indeed it’s actually possible, I’ll be seeking help with the responsiveness.
Well, it’s an odd one for sure. In regex the ^ matches the beginning of a string. So the regular expression ^ matches any string that has a beginning, so every string
The effect is exactly the same as the regular expression ^(.*)$, but faster (because it knows faster that it has a match and can stop evaluating the rest of the string).
since .co.uk at the end of your URL will never be followed by anything, and I’ve added [NC] there to make it case insensive (so it also works on www.TheAlexanderTechnique.co.uk).
Redirect HTTP non-www to HTTPS www in one go, instead of in two steps (first https, then www)
Use 301 status code for permanent redirects, instead of the default 302 for temporary redirect, so link juice is attributed correctly.
(Save the R=301 for last, keep it out at first when you test, so it stays [R,L]. Once you’ve changed the code and verified all works, then change R to R=301. The reason is that browsers cache 301 responses, so if the redirect is wrong, all users hitting your site will have wrong information in their cache. It’s quite hard to correct for that.)
Yes. I think it’s time to determine if it’s your use case, and if so what, why, and most importantly how to fix it.
My completely wild guess is that you developed on your local machine. Maybe you did something like edit the HOSTS file that you’ve since forgotten doing? When you use any other machine than one you developed on, is this still a problem ?
Tried everything; removing web-browsers from my phone and re-installing. Doing the same on my wife’s phone and on the cat’s too.
Thought I’d missed something really obvious or fundamental yet I’d manged to get the mobile redirect working ( with the help of google ) except for the sub-pages bit hence my shout for help.
Might see what my web-host says. Maybe they can see something in the logs that explains it.
Thanks for everyone’s time and efforts. Much appreciated.
I tried to configure the redirect for the mobile site using a regex, but I was not able to find the exact pattern to full fill all of the requirements for the URL rewrite.
Does that make sense to anyone? I suspect that they don’t understand. as I’m not trying to rewrite main site URL’s to equivalent mobile URL’s.
Apparently my host, Siteground, moved from Static Cache to NGINX Direct Delivery which means standard apache rewrites don’t work! Wish someone had advised me sooner though.