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
-
Old Content after 301 Redirect Success
Hi, I want to ask what need I do to the old content after my 301 redirect to the new domain with the same content success? Do I need to remove that old content? Nothing bad happen right? Thanks
Technical SEO | | matthewparkman0 -
301 redirects don't work properly
Hello all, I've been working on 301 redirects for a bit and normally it's no problem but some seem to be going wrong. Redirect 301 /3-zits.html http://www.bankstellenshop.com/banken/3-zits.html This one works properly but the following one gives a very strange result as it goes to http://www.bankstellenshop.com/bankstellen.html/u (no idea where the .html comes from) Redirect 301 /bankstellen/u http://www.bankstellenshop.com/bankstellen/u.html Any idea what I'm doing wrong or what should change? Thanks in advance!
Technical SEO | | Kapottefietsband0 -
301 redirect chains
Hi everyone, I've had my site for a while now and have changed the structure a number of times. I'm confident my 301's work well and am not concerned about dead ends on my site. My question is, is there a way to find 301 redirect chains? i.e. can I export my link data from webmaster tools and run it through some software that tells me how many steps my 301's are taking to get to the final page? I don't know for sure that there are long 301 chains in my link structure, but I have a suspicion and it's very hard to check by going through them manually. Thanks in advance Will
Technical SEO | | madegood0 -
What is the difference between 301 redirect to 404 vs just 404.
A bunch of pages on my site are set to 301 redirect to our 404 page. Intuitively, I feel like they should all just 404 from the page's url and not redirect to the 404 page. How do I explain to my developer that they should not redirects but should just 404? Is there much of a difference between the redirect first vs 404 first? Thanks!
Technical SEO | | gaytravel0 -
Is Buying Domains Good For SEO? Can I 301 redirect domains to an Original website?
I have a friend that purchased multiple domains related to their website. Each of these domains have the back ground of the original website and irrelevant content on them. Is is possible to redirect the various domains to certain pages on the original website. For example if the website is www.shoes.com and they purchased domains such as www.leathermensshoes.com and a few others related to the website. Is it SEO friendly to link the domains purchased to the original website?
Technical SEO | | TSpike10 -
301 Redirect Domain or 301 Redirect Domain + Interior Pages
Hello - My company acquired another company in our industry and our IT team immediately set up the acquired companies domain name as a an alias to our site. This created a duplicate version of our website under another domain name and Google started ranking interior pages from the aliased acquired site for several top keywords that were previously held by our real site. Should we 301 redirect just the top level domain name of the acquired site to the real site or 301 redirect the top level domain name and the interior pages on the acquired site to help ensure that our real domain will take back the rankings it once had? Thanks!
Technical SEO | | Room2140 -
200 Redirects for SEO instead of 301
We are working with a company on re-platforming our website. On a call yesterday they outlined a strategy to use 200 redirects for our top keywords instead of 301s. I am not familiar with this type of redirect and was wondering if anyone could provide some more insight.
Technical SEO | | EvergladesDirect0 -
301 redirect
We have just had an outside SEO agency report on our site: One of things brought up were arounf broken links, and how they class them as broken links. Could any body tell me whether this statement holds true please, as I am not aware of this "Our latest intelligence shows that google are downgrading ranking from sites that feature 301 redirects within the internal link structure". Any help would be greatly appreciated Regards
Technical SEO | | Yozzer0