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
-
Should I set 301 Redirects or keep old permalinks?
I just built a new site for a client and the new site has pretty links like domain.com/about-us. The old site has been around for a VERY long time and had links like domain.com/aboutus. I want to do 301 redirects because from my understanding, it minimizes the negative SEO impact. But the client wants to keep the permalinks without the hyphens to match the old links. What is the best route, considering SEO? BTW, the site is still on the same domain. Thanks in advance for your help! Neik
Technical SEO | | glassh0use0 -
Google Deindexing Site, but Reindexing 301 Redirected Version
A bit of a strange one, a client's .com site has recently been losing rankings on a daily basis, but traffic has barely budged. After some investigation, I found that the .co.uk domain (which has been 301 redirected for some years) has recently been indexed by Google. According to Ahrefs the .co.uk domain started gaining some rankings in early September, which has increased daily. All of these rankings are effectively being stolen from the .com site (but due to the 301 redirect, the site loses no traffic), so as one keyword disappears from the .com's ranking, it reappears on the .co.uk's ranking report. Even searching for the brand name now brings up the .co.uk version of the domain whereas less than a week ago the brand name brought up the .com domain. The redirects are all working fine. There's no instance of any URLs on the site or in the sitemaps leading to the .co.uk domain. The .co.uk domain does not have any backlinks except for a single results page on ask.com. The site hasn't recently had any design or development done, the last changes being made in June. Has anyone encountered this before? I'm not entirely sure how or why Google would start indexing 301'd URLs after several years of not indexing these.
Technical SEO | | lyuda550 -
Is there anyway to automatically find complete urls for 301 redirects?
Hello all, I'm working on a large site that is being prepared for a migration. After scraping on screaming frog, WMT, and deepcrawl, and deduping I have a list of 404 pages that need redirected. Many of these URLs are just incomplete URLs. For example the incomplete URL would be: "https://moz.com/beginners-guide-to" when it should be "https://moz.com/beginners-guide-to-seo" I have been finding the correct page manually searching google. With hundreds more to go, I am looking for a way the would be a little less laborious. Thanks! https://moz.com/beginners-guide-to-seo
Technical SEO | | AdamBohr0 -
301 redirects- how long to keep and how many are too many?
Hi, I was told we have way too many 301 redirects on our site. We have some that have been there for 3 years. Our site is datacard.com . Question- how long should you keep a redirect out there when building a new page and expiring an old page? Is it 6 months, is it a certain time frame? wondering what the best practices are? Thanks! Laura
Technical SEO | | lauramrobinson320 -
301 redirect with Magento; still Page authority 0 after 6 weeks
Hi Mozzers! In December '14 I have execute a 301 redirect in the 'old' page in the admin of my Magento store. Now I was surprised to see that the Page Authority is still 0 of the new page 6 weeks after the execution. should I have seen the update of the PA on the new page already after 6 weeks of time? If yes, then I assume that my Magento didn't execute this properly? Old url: http://hippemamashop.nl/mama/boeken/fotoalbum.html
Technical SEO | | aznventure
New page: you will be redirected to the new page after clicking the old page Mm4uBEl0 -
Where is the 301 redirect?
Hi, in the last week I take an issue for 301 permanent redirect for a subfolder in the main website! In that folder i have a index.php file for a google map fullscreen edition and the only link who connects the wordpress website with the subfolder is only a direct link! Is that an error of seomoz app or something else? Thanks 1.jpg
Technical SEO | | petrospan0 -
301 redirect from root to /index.aspx
I have taken over the SEO for www.domain.net. The way i've inherited the setup is that www.domain.net is 301 redirected to www.domain.net/index.aspx Looking at top pages and linking root domains in Opensiteexplorer I can see that www.domain.net/index.aspx has 1,006 linking root domains www.domain.net has 806 linking root domains. I assume that www.domain.net is passing the value of it's 806 domain links to www.domain.net/index.aspx via the 301 redirect and because of this would expect www.domain.net/index.aspx to be the strongest page on the site and be the url that ranks in the listings for many relevant searches. It appears however that www.domain.net is what is shown in listings and not www.domain.net/index.aspx ?? Can anyone explain why this might be?? If I do a site: search in Google then www.domain.net is indexed and not www.domain.net/index.aspx ??
Technical SEO | | QubaSEO0 -
Should I 301 redirect my country specific sites, or use them as linking root domains?
I have loveelectronics.co.uk, but I also own 10 other country code specific domains. I am short on links (i'm actually still setting up the website) and wondered that until i have country specific content, should I 301 redirect these websites to the homepage of my main site, or could I use them as links which would mean I have more linking root domains? Sorry if this is a beginner question, but it would be good to know so I can sort this.
Technical SEO | | jcarter0