301 redirect
-
What is a proper way to redirect any url containing a give word (anywhere in the url) to another sepcified url? Is it like this?
RedirectMatch 301 ^thisword$ http://domain.com/newlocation
-
well done sha, i am afraid i got the wrong end of the stick, i thought he wanted to SELECT the url, not simply detect it.
-
Glad you got it worked out
Don't forget if you need extra help on something you can always use the Private Message system in your profile to contact people direct.
Have a great weekend,
Sha
-
Yes, Sha looked at it and got a bit lost at once. I am totally new to server side codes and it needed a little modification but i got it working in the end. Thanks a lot.
-
Hi Zsolt,
Did you actually look at the link I gave you with the code that you needed?.
The answer is to stop trying to use Redirectmatch and use the code I gave you in that example:
RewriteEngine on RewriteBase /score RewriteCond %{QUERY_STRING} score= RewriteRule ^/*$ newlocation.html? [R=301,L]
This is the simplest, cleanest, and most reliable solution to your problem.
Sha
-
Thanks for the help. Regretfully this is my very first time writing htaccess so lot of faults can occur. I posted another thread maybe someone knows better than I do. Thank you very much for your time.
-
Well that will select your url, but what are you trying to do with it.
i have it working on IIS server using that regex, but i cant tell you how to use it in htaccess, as i dont use it
-
nothing works. maybe I'll try posting another thread.
-
Here this will select your whole url
[a-z,0-9,=&?/.]score[a-z,0-9,=&]
-
[a-z,0-9,=,&]alan[a-z,0-9,=,&]
get the idea
-
try [a-z,0-9]score[a-z,0-9]
-
You are correct, give me a munite and ill get back to you
-
Still not working for me. I tried further with:
RedirectMatch 301 [.]score[.] http://domain.com (I thought a-z stands just for letter and urls contain number and marks)
RedirectMatch 301 [.]score[.] http://domain.comneither works
-
i work on microsoft servers, so i am not sure about the sytax of htaccess.
but the regex is the same.
please try these.
RedirectMatch 301 [a-z]score[a-z] http://domain.com
RedirectMatch 301 score http://domain.comyou missed the *
-
still not working for me.
The exact url is domain.com/?score=4&rew=25 (there are some more versions of course with different counters)
I want to redirect all urls like this to domain.com
tried:
RedirectMatch 301 /[a-z]score[a-z] http://domain.com
RedirectMatch 301 /.score. http://domain.com
RedirectMatch 301 /^score$.* http://domain.com
RedirectMatch 301 /.^score$.* http://domain.comnone of them woks
-
Did you try it, it works for me.
Just try simply thisword
it should match aaaathiswordaaaaa
this will work,
[a-z]thisword [a-z]
but so will
thisword
-
Thanks, Alan. Not really like that, as my url contains additional characters both in the front and at the end of the word. By the way the links you sent me on the topic were great I am just having some hard time to understand them, they are a bit chinese to me, as I have no basics at all writing htaccess.
-
Thank you a lot for your help, very much appriciated
-
the ^ symbol means the begins with, the $ means ends with
so ^thisword$ means the URL must be a exact match "thisword"
try simply thisword
-
Hi again,
We set up an example page for you with working tests and links to example code and zipped version.
Hope that is what you need,
Sha
-
I think it should be something like
Redirectmatch 301 /.
*thisword.``* http://domain.com
Maybe but I am not sure, would be grateful for feedback
-
You got it right
-
I'm looking for a method to redirect any urls containing a certain variable. I have a scorable element on my site and each time a new score is added a new url is generated like domain.com/xyz?score=5 or domain.com/score=4&rew=22. These are all alternates of my main page abd I would like to redirect them there. In the end found something when clicking through from Jennifer's post but I'm still not quite sure.
-
Hi Zsolt,
Just so we understand exactly what you are asking here ...
What you are wanting to do is permanently redirect any and all URLs containing "thisword" to a single URL on the same domain? Is that accurate?
Sha
-
Ok, as I'd like to help, just looking at your exact question then:
Is it like this?
RedirectMatch 301 ^thisword$ http://domain.com/newlocation
My answer was:
**RedirectMatch 301 /folder/filename.php http://www.domain.com/newlocation** is probably what you're after anyway going by your example in your question. which seems to answer the question asked, just provided a lot more information to help further. If that's not what you're after, could you rephrase the question so that you can get the help you are after? Regards Simon ```
-
Not exactly what I was looking for but thanks for the feedback anywy
-
Hi Zsolt
You'll find a blog post here on SEOmoz really useful, entitled "URL Rewrites and 301 Redirects - How Does It All Work" by Jennifer Sable Lopez (SEOmoz Staff).
There is a section on the '301 Redirect process', you may also find the first section 'URL Rewrites' helpful.
There are some useful links within, depending on whether you're using Apache or IIS. The reason for the redirect and your technical environment will determine the most appropriate way.
RedirectMatch 301 /folder/filename.php http://www.domain.com/newlocation
is probably what you're after anyway going by your example in your question.
Also some really helpful information at http://www.seomoz.org/learn-seo/redirection
Hope that helps,
Regards
Simon
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
-
Best way to handle 301 redirects on a business directory
We work with quite a few sites that promote retail traders and feature a traders' directory with pages for each of the shops (around 500 listings in most cases). As retail strips, shops come and go all the time, so I get a lot of pages that are removed as the business is no longer present. Currently I've been doing 301 redirects to the home page of the directory if you try to access a deleted trader page, but this means a ever growing htaccess file with thousands of 301 redirects. Are we handling this the best way or is there a better way to tackle this situation?
Technical SEO | | Assemblo0 -
301 Redirect domain with penalty
Wondering if I could get a few views on this please... I have added an affiliate store to a domain I own, however I forgot to noindex the product pages which were duplicate content of the merchants. Despite a good deal of backlink building the site will not do much in the engines at all, doesn't even come up on the first few pages for it's own name! This suggests to me that I have a duplicate content penalty. Try as I may I cannot get it removed so am thinking of cloning the domain to a new domain, however, I do not want to lose the links I collected so I am planning on 301ing them. While I will not get all the link power moved over, I should at least get credit for some of them which will kick start the new domain. Can anyone forsee any potential issues with doing this? Is there a danger of 301ing a site with a penalty that the penalty would be carried over? I know there is no penalty on the links, no WMT warnings etc, it is the content causing the issue. Thanks, Carl
Technical SEO | | Grumpy_Carl0 -
Site blocked by robots.txt and 301 redirected still in SERPs
I have a vanity URL domain that 301 redirects to my main site. That domain does have a robots.txt to disallow the entire site as well. However, for a branded enough search that vanity domain still shows up in SERPs and has the new Google message of: A description for this result is not available because of this site's robots.txt I get why the message is there - that's not my , my question is shouldn't a 301 redirect trump this domain showing in SERPs, ever? Client isn't happy about it showing at all. How can I get the vanity domain out of the SERPs? THANKS in advance!
Technical SEO | | VMLYRDiscoverability0 -
Crawl Diagnostic: Notices about 301 redirects
There are detected five 301 redirects on my site and I want to understand why this is happening? And is this important to fix? http://domain.cl/subfolder ---- redirects to ----> http://domain.cl/subfolder/ What does this tell me "/" I am very curious 🙂 Thanks for every answer
Technical SEO | | inlinear
Holger0 -
How to know what pages are 301 redirecting to me?
Hi! It is easy to know if somebody is spam linking your website, looking i.e., looking at open site explorer to analyse the links profile. But, is it possible to know if a competitor of mine is redirecting a bad domain to main with a 301 redirect, thus transfering any bad SEO reputation to me? Best Regards, Daniel
Technical SEO | | te_c0 -
301 Redirect without specifying base domain?
Hi guys, about 10 minutes ago, I finally found the underlying problem in magento between 301 redirects and canonical tags - part of the reason why it was hard to identify was because the problem is not constant through all pages. Anyway now that I found the problem, I have about 50 301 redirects to implement via .htaccess. Now I know the regular syntax is Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html But I'm wondering if there's a way that the base domain doesn't have to be specified in the second half of this line. Something like: Redirect 301 /oldpage.html /newpage.html I'm sure this can be done, somehow. Thanks!
Technical SEO | | yacpro130 -
302 to 301 redirect confirmation
Hi guys, Fairly sure of the answer from what I've read so far, but I just wanted to doublecheck I have it right. Page A gets a significant amount of referring, followed traffic, and also ranks in Google. Page A uses a 302 redirect to Page B (on a completely different domain), which means that 0% of Page A's link juice is being passed on to Page B. If I were to change the 302 redirect to a 301 redirect, then the link juice passed on to Page A from the followed, referring traffic will be (mostly) passed on to Page B. Is that correct? Cheers, Jez
Technical SEO | | jez0000