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 redirects a deal breaker for Migrating content or moving to new software?
I have this forum with about 2 million posts for 16 years on root of the domain. I am looking to switch softwares but the top ones won’t help setup 301 redirects. But I can still migrate all my members and all my content (threads/posts), would Google still reindex all our content or if we don’t setup redirects would it really kill our entire traffic for a long time or maybe just a month or so? I really want to migrate to software that isn’t forum based but rather something that offers courses, chat, live video streaming, subscription based etc. and this is the only way to do so OR to set it up on an entirely new domain OR subdomain but to me that is like starting all over from scratch? I could archive the forum to read only and set it up on subdomain or another root domain - then on the archived forum setup banners and a pop up linking to the new site or new subdomain? . This is such a hard decision for us as the current forum we have had for so many years has lost members posting from 1k a day to just a handful a day, our fb group though gets 1k a day so I’m trying to revive a site into something more modern and has all the training features we can offer as well.
Technical SEO | | vbsk1 -
Will doing a 301 redirect for one domain to another give the latter domain the formers links?
I have some websites that I built a few years ago that are still in existence, but I no longer have access to the sites as they weren't hosted by myself. These sites all carry a "Designed by Me" text on the footer with a link to my (now old) website. I have since done 301 redirects on the domain names that are used in the footers of these sites so they link directly to my new site. However, will these websites now show up on Google Webmasters for example as external links to my site?
Technical SEO | | mickburkesnr0 -
301 Redirect Attribute-Based Dynamic URL to Renamed Attributes
I work with a number of ecommerce sites that have dynamically-created urls based off of product attributes we've assigned in our cms. I am updating a handful of these attributes to more seo-friendly terms because they are outdated but am not certain how to go about redirecting all the urls that each attribute is in/could be in. For example: If I had the attributes hoagie and beanie and changed them to sandwich and headwear, a dynamic url might change like this: .com/hoagie/french-bread ---> .com/sandwich/french-bread .com/beanie/hoagie/novelty ----> .com/headwear/sandwich/novelty Since the urls are dynamically created, I am not sure how I go about redirecting all of them, or if I need to redirect all of them at all (instead just redirecting the urls indexed by Google, etc.) I also have a number of links within copy on each of the sites that contain linked anchor text using attributes that will be changing. I am assuming I will need to 301 each of these or update them manually to reflect the new attributes. I am new to the seo field and would appreciate any and all advice or direction to guides and tutorials that could aid me with this project. Thanks!
Technical SEO | | OfficeFurn0 -
Link juice and 301 redirects
Hi, I have a page with a lot of links going to it. I want to change the name of the page (thereby changing the URL). I can do a 301 redirect, but does a 301 send the "link juice" to the new page? The page in question is www.aerlawgroup.com/dui.html, and I want to change it to www.aerlawgroup.com/dui-lawyer.html. Thank you in advance for your time.
Technical SEO | | mrodriguez14400 -
Creating a Target URL For 301 Redirect in Wordpress
I am confused as to what to put in as the target URL. Is this just a new URL that I must create a name for? I am having trouble finding any answer for this on the internet, just more people asking the same question. I am finally realizing that all the information is found right here at SEOmoz to both learn and ask questions about.
Technical SEO | | lartinos0 -
301 redirects
At the moment it's possible to access the home page of my website via two different urls, with and without www. and you've told me that this can be resolved with Canonicalization and a 301 redirect. Do I do this with my web hosting package or in my html pages? If I can't do it with my web host (1&1) then is there an idiot's guide of how to do it yourself? I've also got both the domain vamospaella.co.uk and vamospaella.com. Is it better to have one of these redirecting to the other for UK traffic (at the moment .co.uk redirects to .com) Thanks
Technical SEO | | melissa10 -
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