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
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
-
301 Redirect - Rank Recovery Examples?
Hi All, I recently did a 301 redirect. Page to Page and the notified google via its console. Its been 6 days since. The home page and one other high traffic page swopped out with the new domain on google search index with 3-4 drops in ranking for each. The rest of the sites pages have been indexed but still reflect the old domain when searched. Recently today my home page dropped even further to the second page of google index for the specific keyword. Can you share similar experiences and how long it took you to recover rank fully? and how long for all pages to swop out on google search's index? Regards Mike
Intermediate & Advanced SEO | | MikeBlue10 -
How to redirect an url in .htaccess when "redirect 301" doesnt work
I have an odd page url, generated by a link from an external website, it has: %5Cu0026size=27.4KB%5Cu0026p=dell%20printers%20uk%5Cu0026oid=333302b6be58eaa914fbc7de45b23926%5Cu0026ni=21%5Cu0026no=24%5Cu0026tab=organic%5Cu0026sigi=11p3eqh65%5Cu0026tt=Dell%205210n%20A4%20Mono%20Laser%20Printer%20from%20Printer%20Experts%5Cu0026u=fb ,after a .jpg image url, and I can't get it redirect using the redirect 301 in .htaccess to the properly image url as I use to do with the rest of not found urls eg: /15985.jpg%5Cu0026size=27.4KB%5Cu0026p=dell%20printers%20uk%5Cu0026oid=333302b6be58eaa914fbc7de45b23926%5Cu0026ni=21%5Cu0026no=24%5Cu0026tab=organic%5Cu0026sigi=11p3eqh65%5Cu0026tt=Dell%205210n%20A4%20Mono%20Laser%20Printer%20from%20Printer%20Experts%5Cu0026u=fb to just: /15985.jpg
Intermediate & Advanced SEO | | Status0 -
Circular Canonical/Redirect
My client's site has an issue (see below) and I'm wondering how much it could be affecting crawlability. Has anyone seen a major rankings bump after fixing something like this? 1. In each page the rel=canonical is pointing to the http version of the page while the http version is redirecting to the https version. Basically, a circular redirect-canonical loop is occurring.2. The sitemap.xml is also referring to the http version of the pages rather than the https.
Intermediate & Advanced SEO | | elenaroi0 -
Redirection not working
http://elmanarah.com/ to http://www.elmanarah.com/ I have mistakenly created 5 databases for one wordpress installation.In order to get rid of them I mistakenly even deleted the right one.Now created the new one but the URL is showing with www Even now if It type in http://elmanarah.com/ it sends me to http://www.elmanarah.com/ I also check in URL D.A and P.A in OSE it shows like I have redirected it fine.Can anyone Check in and guide me either I have done it right and It pass on my previous work effort or it was total loss for me?
Intermediate & Advanced SEO | | csfarnsworth0 -
Homepage 302 redirect - Which option makes most sense?
Edit: Here's a simplified version of this issue and how I have fixed it thus far. On AmbitionSnowskates.com, there is a video section. There is no content on this page, it 302 redirects to the newest video. If you access ambitionsnowskates.com/video/, you are redirected to ambitionsnowskates.com/video/safari-time/. The original post (OP) was about a site with recurring events. There is a cycle between to which subpage the homepage should redirect. For this reason, I was wondering if I should redirect mysite.com to mysite.com/active-subpage/ or the other way around (and have the content directly on the homepage). I was also wondering how this will affect the result in SERPs. It turns out Google shows the title and description of the destination page, but shows the URL of the original URL (the homepage). Knowing this, I can tailor my meta descriptions to be about both the company and the current event; a mix of the two means I won't have to switch or duplicate meta descriptions between active events. I do appreciate the real solution though: in my opinion there should be unique content on the homepage with according CTA. I'm trying to push this as the best fix, with redirections being an alternative, but albeit more complex, solution. Again sorry for being so unclear. I wish I had had an example from the beginning. 🙂 I'm leaving this opened in case someone wants to chime in. Ben Hey guys, I need a hand on this one 🙂 We have a website with 3 events and we want the homepage to show the upcoming event. Event 1 is in February Event 2 is in April Event 3 is in June These events are recurrent year after year. Currently the homepage shows the content of event 1 at the root level (site.com/) . The other events have a unique URL (site.com/event-2, site.com/event-3). Later in the year, after event 1 is over, we change the homepage content to event 2 and move event 1 to its own URL. In other words... Current structure Today: Event 1: site.com/ Event 2: site.com/event-2 Event 3: site.com/event-3 In March: Event 1: site.com/event-1 Event 2: site.com/ Event 3: site.com/event-3 And so on. I want to make sure each event has its own URL and is properly indexed. Option A I can redirect the homepage to the right event: site.com -> 302 -> site.com/event-1. If that's the way to go, what will be the SEO impact, i.e. what content will show up in SERPs? The destination page's content/meta description and title? Option B What I could also do is keep the current structure (content moved to the root), but redirect temporarily the event's unique URL to the homepage: Today: Event 1: site.com/ Event 1: site.com/event-1 -> 302 -> site.com/ Event 2: site.com/event-2 Event 3: site.com/event-3 In March: Event 1: site.com/event-1 Event 2: site.com/ Event 2: site.com/event-2 -> 302 -> site.com/ Event 3: site.com/event-3 And so on. Again, if that's the way to go, how will this impact SERPs, which title and description will I see for the homepage and individual events? If you have other options, I'm all ears! Thanks a lot! (I mean it) -Ben
Intermediate & Advanced SEO | | BenoitQuimper0 -
Redirecting a Page from Domain A to Domain B
We have a page on Domain A, an established and well-ranking website, that would be more appropriate on Domain B, a site that we launched about two years ago. This page ranks well, pulls nice search traffic and has traffic from external links. We would like to move the page and its traffic from Domain A to Domain B using a 301 redirect. Have you ever done this or have you heard of how it has worked for someone else? Thanks!
Intermediate & Advanced SEO | | EGOL0 -
How do I 301 Redirect a complete folder?
Hi, I am want to delete a folder and all the contents. I then need to redirect anyone that is trying to reach a file in that folder to another page on my site. example: www.mydomain.com/folder/ (contains 50 pages) I want to delete the folder and all 50 pages. So if someone tries to reach www.mydomain.com/folder/page1.php the redirect would take them to a specific page on my site. Doing this to clean up old content. How would I do this on the .htaccess? I have redirected a page but not a folder. Thanks in advance! Force7
Intermediate & Advanced SEO | | Force70 -
GeoIP - Redirect all but target country
My client would like to redirect all non UK traffic from their UK site to their main group site. I am intending to use a .htaccess redirect, like this: RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^GB$
Intermediate & Advanced SEO | | cottamg
RewriteRule ^(.*)$ http://www.group.com$1 [R,L] I have tested the redirect at it works fine. My question is if I put this in place would it have any negative SEO impact on the UK site?0