301 Redirect htaccess
-
Hi Guys,
I have a website that has plenty of links with parameters. For example:
http://www.domainname.co.uk/index.php?app=ecom&ns=catshow&ref=Brandname-Golf-Shorts&sid=201v04gxs2hlozv161tfo43qk98583elI 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,
Brucz -
Hi Mark, has your question been answered?
-
Hey Mark,
did this work for you?
Would be happy to hear back.In the meantime enjoy your weekend
Christoph
-
Hey Mark,
it is only 07:21 right now, but I updated my original answer.
Hope you still accept my premature answer
Christoph
-
Hey Christoph,
No worries, yes anything pre 8am is a risk (coffee depending)!
Look forward to your next deep post 8am comment
Cheers
Mark
-
Hey Mark,
I should not answer questions in around 6 a.m. Sorry for that
My example works only when you want to redirect from an old domain to a new one - or from http://www.domain.com to http://domain.com
If you want the links to be on the same domain, things get tricky quite fast. I'll deep dive into the documentation and be right back
-
Hey Christoph,
Glad our needs can spring you into action
Appreciate that very much, will test it out in the morning and post my findings.
Thanks again, thats great.
Mark
-
Hey Mark,
Finally a question that I can answer (yay!)
I use the following code on my website:
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteRule ^(.*)$ http://www.it-engelhardt.de/$1 [R=301]</ifmodule>It basically takes every URL like http://itengelhardt.de/microconf-2013-hub-page/
and just redirects it (301 of course!) to http://www.it-engelhardt.de/microconf-2013-hub-page/
UPDATE 1: (after carefully re-reading the question)
OK, hopefully this is the correct answer to your question:
**Assumptions I made: **
- You want to extract the category name from the query string (i.e. everything after the '?')
- "ns=catshow" in the query string stands for "category show" and tells the server to show a category
Then this is hopefully what you want:
RewriteCond %{QUERY_STRING} ns=catshow
RewriteCond %{QUERY_STRING} ref=([^&]+)
RewriteRule ^index.php /Category/%1? [R=301]**What it does: **
- checks if "ns=catshow" is present in the query string
- extracts the value from the "ref=" variable in the query string and stores it in %1
- rewrites every request to the server, that matches conditions 1. and 2. and starts with "index.php" to /Category/%1
4. the "?" at the end of "/Category/%1?" tells the server to throw away the original query string - this might not be desirable, if not: remove the '?'
5. the [R=301] tells the server to redirect using HTTP 301Tested with: http://htaccess.madewithlove.be/
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
-
Recovering from an open redirect
From a previous company we have inherited a domain which once contained an open redirect redirect.magnet.me. Even though this domain has been returning a 410 for every single request directed at it for the last few months, we continue to see new links popping up in Google which refer to this domain https://www.google.com/search?safe=off&q=%22redirect.magnet.me%22 Currently we just keep disavowing these links, but at the same time they keep appearing in our Moz.com tooling, being unable to disavow those links here. Does anybody have any successful tips how to deal with this scenario, compared to only disavow new links after the fact?
Intermediate & Advanced SEO | | rogier_slag0 -
(Urgent) losing traffic after 301 redirect
We face a seo problem of losing traffic after 301 redirect.We have used 301 redirect from a sub-domain url to main domain, after a few month, we discovered that the traffic in google is dropped 40% as well as yahoo dropped 50% without reason, we have updated sitemap already, but we cannot find any reason for the traffic dropped till now..The original url (more then 5000 links)https://app.example.com/ebook Redirected Urlhttps://www.example.com/ebookThank you for your help!
Intermediate & Advanced SEO | | yukung0 -
New Site (redesign) Launched Without 301 Redirects to New Pages - Too Late to Add Redirects?
We recently launched a redesign/redevelopment of a site but failed to put 301 redirects in place for the old URL's. It's been about 2 months. Is it too late to even bother worrying about it at this point? The site has seen a notable decrease in site traffic/visits, perhaps due to this issue. I assume that once the search engines get an error on a URL, it will remove it from displaying in search results after a period of time. I'm just not sure if they will try to re-crawl those old URLs at some point and if so, it may be worth it to have those 301 redirects in place. Thank you.
Intermediate & Advanced SEO | | BrandBuilder0 -
301 redirection pointing to noindexed pages
I have rather an unusual situation where a recently launched affiliate site does not have any unique content as its all syndicated content. For that reason we are currently using the noindex,nofollow meta tags to keep the pages out of the search engines index until we create unique content for the pages. The problem is that due to a very tight timeframe with rebranding, we are looking at 301 redirecting (on a page to page basis) another high authority legacy domain to this new site before we have had a chance to add unique content to it and remove the noindex,nofollow tags. I would assume that any link authority normally passed through the 301 would be lost in this scenario but Im uncertain of what the broader impact might be. Has anyone dealt with a similar scenario? I know this scenario is not ideal and I would rather wait until the unique content is up and noindex tags are removed before launching the 301 redirect of the legacy domain but there are a number of competing priorities at play outside of SEO.
Intermediate & Advanced SEO | | LosNomads0 -
URL Structure Change - 301 Redirect - on large website
Hi Guys, I have a website which has approximately 15 million pages indexed. We are planning to change url structure of 99.99% of pages but it would remain on same domain. eg: older url: xyz.com/nike-shoes; new url: xyx.com/shopping/nike-shoes A benefit that we would get is adding a related and important keyword in url. We also achieve other technical benefits in identifying the page type before hand and can reduce time taken to serve the pages (as per our tech team). For older URLs, we are planning to do a 301 redirect. While this seems to be the correct thing to do as per Google, we do see that there is a very large number of cases where people have suffered significantly on doing something like this : Here are our questions: Will all page rank value will be passed to new url? (i.e. will there be a 100% passing of PR/link juice to the new URLs) Can it lower my rank for keywords? (currently we have pretty good rankings (1-5) on many keywords) If there is an impact on rankings - will it be only on specific keywords or will we see a sitewide impact? Assuming that we have taken a hit on traffic, How much time would it take to get the traffic back to normal? and if traffic goes down, by what percentage it may go down and for how much time. (best case, average case and worst case scenarios) Is there anything I should keep in mind while doing this? I understand that there are no clear answers that can be given to these questions but we would like to evaluate a worst case/best case situation. Just to give context : Even a 10 day downtime in terms of drops in rankings is extremely detrimental for our business.
Intermediate & Advanced SEO | | Myntra0 -
301 redirect subdomain to path and 301 for popular pages
We have very popular pages that have many backlinks. www.chezmaya.com/jeux/game33.htm have so many backlinks and it's very popular. Now If i'm moving this page to a new path like : http://www.chezmaya.com/jeux/component/mtree/Défouloir/Game33/details.html with a 301. Your SEOmoz toolbar is now giving a very low PA:1 and mR:0.00 for this new page. My question is after you crawl my site again would you change the values to what /jeux/game33.htm got before ? We used to have jeux.chezmaya.com and moved to www.chezmaya.com/jeux/
Intermediate & Advanced SEO | | SocialGeekMedia
Same here PA:1 and mR:0.00 for this page. Also Matt Cutts say that Google does transfer the juice from the old page to the new one. I already saw one url changed in a search for puzzle, it's at the same position it was before, but it say's 6 days ago beside. So I wonder if this is temporary and it will move with time? Thanks0 -
301 redirect or rel=canonical
On my site, which I created with Joomla, there seems to be a lot of duplicated pages. I was wondering which would be better, 301 redirect or rel=canonical. On SeoMoz Pro "help" they suggest only the rel=canonical and dont mention 301 redirect. However, ive read many other say that 301 redirect should be the number one option. Also, does 301 redirect help solve the crawling errors, in other words, does it get rid of the errors of "duplicate page content?" Ive read that re-=canonical does not right? Thanks!
Intermediate & Advanced SEO | | waltergah0 -
301 Redirecting multiple domains to brand new domain
Hi guys, I have read quite a bit of stuff on 301 redirects after Penguin. Hoping someone could help me out. im looking at a way to do a legit 301 redirect without passing the penalty. I have acquired two businesses, business1 and business2, that both had websites that were hit by penguin. Ive anaylsed there backlinks and theres a lot of spammy forum links and comments and I was also informed they were both using buildmyrank. A side note, buiness2 only started using BMR after it noticed business1 have large amounts of high PR links. business1.com was ranking at position 1 till the penguin hit. Business2.com was ranking around page 2 I work in the same arena as these two businesses and didnt generate any business via the internet. When these 2 businesses failed (due to loss of rankings and traffic) i decided to take them over. What I am thinking of doing is 301'ing both business domains to my brand new, zero links, domain which will be the name of my new company. I will combine the content from both sites, around 1000 pages, in to the new one. So my question is, does 301'ing multiple domains, that target the same keywords, and operate in the same niche, look less "spammy" then 301'ing 1 domain? I'm trying to look at it in the eyes of google. It is a legit merging of businesses. Thanks for your help, really appreciate your time
Intermediate & Advanced SEO | | JohnPeters0