How to do a wildcard redirect?
-
Sorry if this is a dumb question, but I am not a programmer and my client's programmer is asking me how to set this up. Normally I do it in my cPanel, but they can't and need to write it in the .htaccess file.
The client's new website was posted at dev.site.com and of course their programmer put robots="index,follow" and so the site is completely indexed. They are launching it tomorrow at www.site.com.
I need a wildcard redirect that takes dev.site.com/anything and 301 redirects it to www.site.com/samething if that makes sense. Basically redirects every dev.site.com URL to www.site.com so we don't have duplicate indexation issues.
Can anyone tell me the code to do this that needs to go in the .htaccess file? I would just do it through cPanel but that's not an option, so any help is appreciated.
-
I believe this should solve your problem:
http://stackoverflow.com/questions/7610787/htaccess-wildcard-redirect-fix
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
-
Ranking after redirecting two URLs to a new domain
I run two websites which operate in similar business sectors. Each has a calculator tool that offers the same functionality. The pages rank 2nd and 5th for the key search term. I'd like to improve the functionality of this and have thought about setting up a new domain for this calculator to move it away from the main sites. If I did this and 301 redirected both pages to the new domain do you think I'd maintain a strong ranking position for this search term on the new domain? Thanks for any advice.
Intermediate & Advanced SEO | | craigramsay0 -
Redirecting to a new domain... a second time
Hi all, I help run a website for a history-themed podcast and we just moved it to its second domain in 7 years. We've had very good SEO up until last week, and I'm wondering if I screwed up the way I redirected the domains. It's like this: Originally the site was hosted at "first.com", and it acquired inbound links. However, we then started to host the site on blogger, so we... Redirected the site to "second.blogspot.com". (Thus, 1 --> 2) It stayed here for about 7 years and got lots of traffic. Two weeks ago we moved it off of blogger and into Wordpress, so we 301 redirected everything to... third.com. (Thus, 1 --> 2 --> 3) The redirects worked, and when we Google individual posts, we are now seeing them in Google's index at the new URL. My question: What about the 1--> 2 redirect? There are still lots of links pointing to "first.com". Last week I went into my GoDaddy settings and changed the first redirect, so that first.com now points to third.com. (Thus 1 --> 3, and 2-->3) I was correct in doing that, right? The drop in Google traffic I've seen this past week makes me think that maybe I screwed something up. Should we have kept 1 --> 2 --> 3? (Again, now we have 1-->3 and 2-->3) Thanks for any insights on this! Tom
Intermediate & Advanced SEO | | TomNYC1 -
Login required pages that redirect back to the post
Hi, Login required pages that redirect back to the post get the same description Example http://www.Somesite.com/modal/register?destination=post title Every post when a non member sees it has links that are as above post title is the only difference in the URL's So these Meta descriptions 1,000's of them are same. What can we do Thanks
Intermediate & Advanced SEO | | mtthompsons0 -
301 Redirect htaccess
Hi Guys, I have a website that has plenty of links with parameters. For example:
Intermediate & Advanced SEO | | UrbanMark
http://www.domainname.co.uk/index.php?app=ecom&ns=catshow&ref=Brandname-Golf-Shorts&sid=201v04gxs2hlozv161tfo43qk98583el I want to place a wildcard redirect on the .htaccess but don't know what exactly code for this. Ideally I want the URLs above to be: http://www.domainname.co.uk/Category/Brandname-Golf-Shorts Any help pls. Thanks,
Brucz0 -
2-stage 301 redirects
Dear colleagues, I have quite an unusual situation with one of my client's websites, and I could use an advise from someone who experienced the same circumstances: They are currently planning on launching a new site under the same domain (by September), when several key current pages are intended to be replaced with new equivalent pages under new URLs. So far it's pretty simple, BUT - due to a merger with another company they will be migrating their entire website to a different domain within a year. My question is - what would be the optimal solution for redirects? We are considering a 301 from the current pages to the new pages under the same domain, and once the new domain is activated - aside from defining 301 redirects from the new pages under the same domain to the new domain, we will cancel the original 301 from the old pages to the new pages on the same domain, and instead define new 301 for those pages to the new domain. What do you think? Is there a better solution - like using 302 redirects for the first stage? Has anyone tried such a procedure? Your input will be highly appreciated! Thanks in advance, Omer
Intermediate & Advanced SEO | | Usearch0 -
Canonical or 301 redirect, that is the question?
So my site has duplicate content issues because of the index.html and the www and non www version of the site. What's the best way to deal with this without htaccess? Is it a 301 redirect or is it the canonical, or is it both?
Intermediate & Advanced SEO | | bronxpad0 -
Warning about a 302 redirect
Hello everyone, I'm testing the pro software and recently I installed an SSL Certificate on one of the websites I'm monitoring, I put in place an .htaccess directive to force all traffic to the secure version of the site (https) and I noticed how this raised a warning because my directive is forcing the traffic with a 302 redirect. These are the lines: _RewriteCond %{SERVER_PORT} 80 _ RewriteRule ^(.*)$ https://example.com/$1 [R,L] I understand that this is not good so I figured since I'm already redirecting all www to -www I can force traffic that arrives trying to use www to the secure version like so: RewriteCond %{HTTP_HOST} !^example.com$ RewriteRule (.*) https://example.com/$1 [R=301,L] But this is not 100% effective because if someone visits the site directly on the -www version this person wont get redirected hence it wont be forced to see the https. So my question is: does anybody know of an alternate way to force traffic to the secure socket using a 301 instead of a 302? Oh boy, just by writing the question I think I may have figured it out, I'll post it anyways because (1) I could be wrong and (2) It could help someone else. It just hit me but the directive that is forcing www to -www specifies what type of redirect to do here [R=301,L]. So to try to answer my own question before even posting it this could probably do the trick: _RewriteCond %{SERVER_PORT} 80 _ _RewriteRule ^(.*)$ https://example.com/$1 [_R=301,R,L] I'll be testing it out ASAP and again I'll post the question anyways just in case it doesn't work, in case someone has a good suggestion or to help someone that could be in the same situation. If this is turns out right I will need someone to slap me in the face 😐
Intermediate & Advanced SEO | | stevenpicado0 -
Are there any negatives to channeling my links through a 301 redirect?
I'm channeling 1000's of links through another url with a 301 redirect. I've thought this through and can't see any downside to doing this, but I want to get your opinion. Can you see any downside to doing this? With regards to passing anchor text, PR, PA, etc? Since this is done with sites all the time when they change urls, I can't see Google being able to penalize me for this....can you? What do you think?
Intermediate & Advanced SEO | | Brian-M0