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
-
I have a metadata issue. My site crawl is coming back with missing descriptions, but all of the pages look like site tags (i.e. /blog/?_sft_tag=call-routing)
I have a metadata issue. My site crawl is coming back with missing descriptions, but all of the pages look like site tags (i.e. /blog/?_sft_tag=call-routing)
Intermediate & Advanced SEO | | amarieyoussef0 -
PushState for redirects
Is it possible to use PushState for redirects from one site to another?
Intermediate & Advanced SEO | | rgamedia_seo0 -
Subdomains + SEO
Hi everyone, So a little background - my company launched a new website (http://www.everyaction.com). The homepage is currently hosted on an amazon s3 bucket while the blog and landing pages are hosted within Hubspot. My question is - is that going to end up hurting our SEO in the long run? I've seen a much slower uptick in search engine traffic than I'm used to seeing when launching new sites and I'm wondering if that's because people are sharing the blog.everyaction.com url on social (which then wouldn't benefit just everyaction.com?) Anyways, a little help on what I should be considering when it comes to subdomains would be very helpful. Thanks, Devon
Intermediate & Advanced SEO | | EveryActionHQ0 -
Penalty after 301 redirect?
We run a training center. We had 1 main website and 2 dedicated websites to certain themes. The 2 dedicated websites are older and the main website is about 6 months old. The 2 dedicated websites had a top 5 ranking for their most important keywords. 2 weeks ago we imported all the content from the dedicated websites into the main website. Then immediately after we did a perfect 301 redirect of these websites to the main website. 2 SEO companies checked it for us and so I'm very sure this is done right. Google immediately caught this up and gave the main website a boost. We where in the top 10 for many important keywords for 1 week. The next week all our rankings dropped. We only have a top 50 ranking for 10 keywords. Before it was 75 keywords in the top 20. Do you know what could have caused this? Any suggestion, thought, ... is welcome!
Intermediate & Advanced SEO | | wellnesswooz0 -
Will an inbound follow link on a site be devalued by an inbound affiliate link on the same site?
Hey guys, quick question I didn't find an answer to online. Scenario: 1. Site A links to Site B. It's a natural, regular, follow-link 2. Site A joins Site B's affiliate program, and adds an affiliate link Question: Does the first, regular follow link get devalued by the second affiliate link? Cheers!
Intermediate & Advanced SEO | | ipancake0 -
Site rankings down
Our site is over 10 years old and has consistently ranked highly in google.co.uk for over 100 key phrases. Until the middle of April, we were 7th for 'nuts and bolts' and 5th for 'bolts and nuts' - we have been around these positions for 5-6 years easily now. Our rankings dropped mid-April, but now (presumably as a result of Penguin 2.0), we've seen larger decreases across the board. We are now 5th page on 'nuts and bolts', and second page on 'bolts and nuts'. Can anyone please shed any light on this? Although we'd fallen some before Penguin 2.0, we've fallen quite a bit further since. So I'm wondering if it's that. We do still rank well on our more specialised terms though - 'imperial bolts', 'bsw bolts', 'bsf bolts', we're still top 5. We've lost out with the more generic terms. In the past we did a bit of (relevant) blog commenting and obtained some business directory links, before realising the gain was tiny if at all. Are those likely to be the issue? I'm guessing so. It's hard to know which to get rid of though! Now, I use social media sparingly, just Facebook, Twitter and G+. The only linkbuilding I do now is by sending polite emails to people who run classic car clubs that would use our bolts, stuff like that. I've had a decent response from that, and a few have become customers directly. Here's our link profile if anyone would be kind enough as to have a look: http://www.opensiteexplorer.org/links?site=www.thomassmithfasteners.com Also, SEOMOZ says we have too many links on our homepage (107) - the dropdown navigation is the culprit here. Should I simply get rid of the dropdown and take users to the categories? Any advice here would be appreciated before I make changes! If anyone wants to take a look at the site, the URL is in the link profile above - I'm terrified of posting links anywhere now! Thanks for your time, and I'd be very grateful for any advice. Best Regards, Stephen
Intermediate & Advanced SEO | | stephenshone1 -
301 redirects
Hello, I want to ditch about 1000 pages of a 2000+ page site. I believe the 301 redirect thing is the way to go but my expertise is limited. Is there a way to do a blanket redirect ie if a user or search engine looks for a page thats not there it all gets redirected to the index page or do I have to do each one manually? Thanks Ian
Intermediate & Advanced SEO | | jwdl0 -
Is this site worth subscribing to?
Hi everyone is, the below site worthwhile submitting to? I see one of our competitors is on here and the article they have published has in turn be picked up by other sites. Is the financial cost worth the back link reward? https://app.prweb.com/Main.aspx?Entity=Home
Intermediate & Advanced SEO | | Hardley10