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
-
Is 301 redirect the only way when using Vanity URLs?
We have been using vanity urls for some of our pages. Mostly the pages that have a vanity URL have a long URL length. But now the problem is, the vanity URL is getting displayed on the search engine when the particular keyword related to the page is entered. I checked the google search console, the vanity URL is indexed and the original URL remains unindexed. What should I do? Is adding 301 redirect to the vanity URLs are solution? Since some of vanity URLs are not redirecting to the original. Some of the original pages are not getting traffic. Also, can using canonical tag help?
Technical SEO | | tejasbansode0 -
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 Redirects, Sitemaps and Indexing - How to hide redirected urls from search engines?
We have several pages in our site like this one, http://www.spectralink.com/solutions, which redirect to deeper page, http://www.spectralink.com/solutions/work-smarter-not-harder. Both urls are listed in the sitemap and both pages are being indexed. Should we remove those redirecting pages from the site map? Should we prevent the redirecting url from being indexed? If so, what's the best way to do that?
Technical SEO | | HeroDesignStudio0 -
Does 301 redirect cause penalty
Good Morning, I am considering doing a 301 (permanent) re-direct of roughly 100 domains, split between my 3 main e-commerce sites. Would taking an action like this put any of the 100 domains or any of the 3 recipient domains at risk of violating G's guidelines? Thanks...
Technical SEO | | Prime851 -
301 Redirect From Dynamic Page To Static
I want to 301 redirect all "id" and "type" numbers from my page dynamic.php page (I have thousands of IDs and thousands of Types) all to a single URL. So for example the following.... www.mysite.com/dynamic.php?id=1&type=5 www.mysite.com/dynamic.php?id=2&type=5 www.mysite.com/dynamic.php?id=3&type=5 www.mysite.com/dynamic.php?id=1&type=6 www.mysite.com/dynamic.php?id=2&type=6 www.mysite.com/dynamic.php?id=3&type=6 ...would all be sent to: www.mysite.com/page.html How can this be done without doing a redirect for each ID/Type?
Technical SEO | | TheDude1 -
How many steps for a 301 redirect becomes a "bad thing"
OK, so I am not going to worry now about being a purist with the htaccess file, I can't seem to redirect the old pages without redirect errors (project is an old WordPress site to a redesigned WP site). And the new site has a new domain name; and none of the pages (except the blog posts) are the same. I installed the Simple 301 redirects plugin on old site and it's working (the Redirection plugin looks very promising too, but I got a warning it may not be compatible with the old non-supported theme and older v. of WP). Now my question using one of the redirect examples (and I need to know this for my client, who is an internet marketing consultant so this is going to be very important to them!): Using Redirect Checker, I see that http://creativemindsearchmarketing.com/blog --- 301 redirects to http://www.creativemindsearchmarketing.com/blog --- which then 301 redirects to final permanent location of http//www.cmsearchmarketing.com/blog How is Google going to perceive this 2-step process? And is there any way to get the "non-www-old-address" and also the "www-old-address" to both redirect to final permanent location without going through this 2-stepper? Any help is much appreciated. _Cindy
Technical SEO | | CeCeBar0 -
301 redirects and OSE
We run a blog/video real estate site (yochicago.com) as one of the venues for sponsored content for our clients looking for off-page SEO and inbound links. I'm working with a client who we've linked to a handful of times in the last few weeks, but I'm not seeing any external links from our site on PRO/OSE. Come to find that our writer has been linking to http://clientsite.com, instead of http://www.clientsite.com, which is the canonical site. I wouldn't have thought that this would make a difference, and about an hour of web research seems to confirm that it shouldn't make a difference, save for losing a little bit of SEO credit. What am I missing? Any input would be appreciated.
Technical SEO | | mikescotty0 -
301 redirect: Old pages to new
Hi, We have recently made some changes to our agency site. Looking in webmaster tools we have identified a number of old pages with existing link juice. Not a great deal mostly 32/100 PA. There are a mixture of URLs "meet the team" and people pages etc. The anchor text on the majority of pages is our brand name. Could we now 301 all these pages to one page, or is this a no no in the eyes of Google? Any help greatly appreciated. Best Regards Sean
Technical SEO | | Yozzer0