Code to Redirect Mobile Subdomain to Desktop Site
-
Hi Everyone,
My client is switching from a mobile subdomain to a responsive site. All URLs are the same on mobile subdomain vs desktop so we just need a wildcard rule to redirect m. to www.
Anyone have this wildcard redirect code for an .htaccess file?
Much appreciated!
Dan
-
Well, I worked with the developer that contracts with this client and here's what he put in the .htaccess file (domain replaced with "domain"). It did the trick.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^m.domain.com
RewriteCond %{REQUEST_URI} !^/sitemap.xml$
RewriteCond %{REQUEST_URI} !^/robots.txt$
RewriteRule ^(.*) http://www.domain.com/$1 [R=301] -
I have some code that I think will work. Would appreciate peer review
RewriteCond %{HTTP_HOST} ^m.domain.com
RewriteRule ^(.*) http://www.domain.com/$1 [R=301]I'd like to also avoid redirecting the /robots.txt file and /sitemap.xml file on the mobile subdomain, since I want Google to crawl the sitemap to facilitate faster processing of the redirects. If the code above is correct, how would I add this line of code (below) into the 2nd line of code above?
RewriteRule ^((?!.?.xml|.?.txt|.?\GoogleVerificationFile.html).).* http://www.domain.com [R=301]
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Seo for international sites
Hello, I have a question for the group, our main US site-  http://www.datacard.com is utilized to move content to other regional sites like http://www.datacard.co.uk/ and http://www.datacard.fr/ and http://www.datacard.com.br/.  Anyhow, we essentially have some regional content on those sites, but for ease of maintaining and updating the content we have a company translate this for us and then undergo an in country review for local people in our company to review the content. That being said the meta descriptions, titles, code, everything gets translated to that language. I know there are issue for SEO for these purposes as we get much better rankings with http://www.datacard.com.  The regional sites are newer so this could be part of it. We don't have an agency helping us with SEo and i get a lot of questions on what can be done internally for this for regional sites with our current structure. Any tips you have? It would be greatly appreciated! Laura
Intermediate & Advanced SEO | | lauramrobinson320 -
Franchise sites: Should each franchise have a subdomain or subdirectory?
One of my clients has about 40 franchisees who are going to have their own sites on a WordPress multisite installation. The question they're wondering: should these be on subdirectories (thesite.com/this-franchise) or on subdomains (this-franchise.thesite.com)? Which is best for SEO? Thanks!
Intermediate & Advanced SEO | | ideasandpixels0 -
3 Wordpress sites 1 Tumblr site coming under 1domain(4subdomains) WPMU: Proper Redirect?
Hey Guys, witnessSF.org (WP), witnessLA.org(Tumblr), witnessTO.com(WP), witnessHK.com(WP), and witnessSEOUL.com(new site no redirects needed) are being moved over to sf.ourwitness.com, la.ourwitness.com and so forth. All under on large Wordpress MU instance. Some have hundreds of articles/links others a bit less.  What is the best method to take, I understand there are easy redirects, and the complete fully manual one link at a time approach. Even the WP to WP the permalinks are changing from domain.com/date/post-name to domain.com/post-name? Here are some options: Just redirect all previous witinessla.org/* to la.ourwitness.org/ (automatic direct all pages to home page deal) (easiest not the best)2) Download Google Analytics top redirected domains about 50 urls have significant ranking and traffic (in LA's sample) and just redirect those to custom links. (most bang for the buck for the articles that rank manually set up to the correct place) 3) Best of the both worlds may be possible? Automated perhaps?I prefer working with .htaccess vs a redirect plugin for speed issues. Please advise. Thanks guys!
Intermediate & Advanced SEO | | vmialik0 -
301s from previous site
Hi! Got quite a tricky problem regarding a client, http://www.muchbetteradventures.com/ and their previous site, http://v1.muchbetteradventures.com/ Here's the background: We have approx 1500 'listing' pages like this: http://v1.muchbetteradventures.com/listing/view/1925/the-barre-des-ecrins-or-the-dome-des-ecrins-mountaineering-trip They bring in min 2k hits/month, and also add to the overall site authority I suspect. They will eventually all have a home on main domain. When they do, they will also each have been rewritten to be unique, so the value of them will increase (many are currently not). We also have landing pages like this: http://v1.muchbetteradventures.com/view/559/volunteering-holidays- which despite being hideous are ranked fairly well (page 1 for key terms). We cannot currently fulfil all these on main domain, but do not want to shut them down and lose positioning. Choices as I see it: Make a landing page e.g. muchbetteradventures.com/volunteering and a) redirect from old landing page, b) redirect all related 'listings' to this page. May help preserve rankings of main landing page (the most important), but not of any listings? Import all listings to have a home on main domain, (probably as children of a landing page, but not rewritten to be unique just yet). Make them not accessible from homepage, and change functionality of them so that new visitors from google are told we cannot currently help them with this trip. This is more work to complete so will take longer to do and is a distraction from our core focus so needs good justification! Stay running largely as we are, slowly redirecting 1 page at a time as we carry over more and more options to main domain. This will take over 12 months min.
Intermediate & Advanced SEO | | neooptic0 -
How to decide on which site to 301 redirect
Hi there I'd like your opinions please! My client currently has their website at not-very-good-url.it which has a really good link profile they also have duplicate sites at: much-better-brand-name-url.it and much-better-brand-name-url.com but both these other sites have only a handful of links in. How important do you think a better brand url is? And therefore do you think it would be better to 301 to a better brand URL and take the risk that the link profile will get hit? Or leave the main site where it is and 301 the other two to it? Many thanks
Intermediate & Advanced SEO | | Chammy0 -
2 sites or one sites: 2 locations
Hello, I have a dog training client who is offering services in 2 separate locations. We're looking to be first in the non-local search results and also rank well in google places. Would it be better to go for 2 separate sites or one site and try to rank for 2 different locations with one site? There's both local and standard search results when we type in our keywords. Thanks!
Intermediate & Advanced SEO | | BobGW0 -
My site penalized after 301 Redirect or redesign?
Hi, I have a question regarding my site (http://www.pokeronlineitalia.com) that has, all of a sudden, lost rankings on several keywords; plus, Google Analytics and the plug-in Clicky installed on my site (the site is built on WordPress) claim that my site has no visitors/visits anymore. I would like to provide a little background of what has happened. Three weeks ago I asked my web hosting company to do a 301 redirect from http://pokeronlineitalia.com to http://www.pokeronlineitalia.com. At the same time I asked a web hosting company to to a redesign of the site. Strangely, the day after the new redesigned site went online Google Analytics and the Clicky plug-in showed that my site, from one day to the other, had no visitors/visits anymore (I had installed Google Analytics and Clicky before the 301 redirect). In addition, I noticed that I had lost positions on many keywords for which I used to rank on the second page. However, the PR of the site has remained intact and Google is indexing it without problems. Plus, I still rank high for a keyword. I tend to believe that because of this, my site was not penalized by mighty Google...but I'd like an SEO expert to tell me what he thinks about it. In particular, please answer this: has my site lost rankings because of the 301 redirect? Has my site been penalized because of the redesign? Is this only a temporary situation? Thank you very much for your help. Sal
Intermediate & Advanced SEO | | salvyy0 -
How to Redirect
What is the htaccess code to redirect everything in a directory to a file? Thanks!
Intermediate & Advanced SEO | | tylerfraser0