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
-
Site Speed Testing Tools For Production Sites
Hi Guys, Any free site speed testing tools for sites in production, which are password protected? We want to test site speed before the new site goes live on top priority pages. Site is on Shopify – we tried google page insights while being logged into the production site but believe its just recording the speed of the password page. Cheers.
Intermediate & Advanced SEO | | brandonegroup1 -
Redirects Being Removed...
Hi We have a team in France who deal with the backend of the site, only problem is it's not always SEO friendly. I have lots of 404's showing in webmaster tools and I know some of them have previously had redirects. If we update a URL on the site, any links pointing to it on the website are updated straight away to point to the most up to date URL - so the user doesn't have to go through a redirect. However, the team would see this as the redirect not being 'used' after about 30 days and remove it from the database - so this URL no longer has any redirects pointing to it. My question is, surely this is bad for SEO? However I'm a little unsure as they aren't actually going through the redirect. But somewhere in cyber space the authority of this page must drop? Any advice is welcome 🙂
Intermediate & Advanced SEO | | BeckyKey0 -
Linking to one of my own sites, from my site
Hi experts, I own a site for castingjobs (Site1) and a site for selling paintings (Site2). In a long time, I've had a link at the bottom of Site1, linking to Site 2. (Basicaly: Partnerlink: Link site 2). Site1 is for me the the only important site, since it's where Im making my monthly revenue. I added the link like 5 years ago or so, to try to boost site 2. My question is:
Intermediate & Advanced SEO | | KasperGJ
1. Is it somehow bad for SEO for site 1, since the two sites have nothing to do with each other, they are basically just owned by me.
2. Would it make sense to link from Site 2 to Site 1 indstead?0 -
Is it worth redirecting?
Hello! Is there any wisdom or non-wisdom in taking old websites and blogs that may not be very active, but still get some traffic, and redirecting them to a brand new website? The new website would be in the same industry, but not the same niche as the older websites. Would there be any SEO boost to the new website by doing this? Or would it just hurt the credibility of the new website?
Intermediate & Advanced SEO | | dieselprogrammers0 -
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 -
How are these sites ranking!?!
One of our clients is in the insurance industry and over the last 12 months we have seen an increasing number of low quality, newly registered, spammy sites achieving top 5 rankings for major keywords, which in turn is having an adverse effect on the rankings for our client. Does anyone have any idea how the following sites have managed to do this: http://www.multiquotetaxi.co.uk/ - 2nd for taxi insurance http://www.motortradefast.co.uk/ - 1st for motor trade insurance http://www.traders-insurance.com/ - 3rd for motor trade insurance http://www.multiquotefleet.co.uk/ - 1st for fleet insurance We have tried reporting the above sites, tried holding out to see if they get penalised and tried figuring out what they have done ourselves but cannot see how they have managed it. Any ideas at all?
Intermediate & Advanced SEO | | instinctive0 -
Adding Meta Languange tag to xhtml site - coding help needed
I've had my site dinged by Google and feel it's likely several quality issues and I'm hunting down these issues. One of Bing's Webmaster SEO tools said my xhtml pages (which were built in 2007) are missing Meta Language and suggested adding tag in the or on the html tag. Wanting to "not mess anything up" and validate correctly, I read in **W3C's site and it said: ** "Always add a lang attribute to the html tag to set the default language of your page. If this is XHTML 1.x you should also use the xml:lang attribute (with the same value). Do not use the meta element with http-equiv set to Content-Language." My current html leads like: QUESTION:
Intermediate & Advanced SEO | | mlm12
I'm confused on how to add the Meta Language to my website given my current coding as I"m not a coder. Can you suggest if I should add this content-language info, and if so, what is the best way to do so, considering valid w3c markup for my document type? Thank you!!!
Michelle0 -
Redirect micro-niche site to bigger niche site?
I have a micro niche site that performs reasonably well (page 1 at least) for it's main keywords. It is an exact match domain. To save the ongoing maintenance of a site that gets less than 10 visitors a day, I was thinking of redirecting this micro niche site to a bigger site (a niche site that the micro niche fits into, if that makes sense!) Would I lose rankings because of the power that the EMD provided? Would it be better keeping it there for the backlink it provides to the bigger site (although on the same C Class IP)
Intermediate & Advanced SEO | | BigMiniMan0