301 Redirect for multiple links
-
I just relaunched my website and changed a permalink structure for several pages where only a subdirectory name changed.
What 301 Redirect code do I use to redirect the following? I have dozens of these where I need to change just the directory name from "urban-living" to "urban", and want it to catch the following all in one redirect command.
Here is an example of the structure that needs to change.
Old
domain.com/urban-living (single page w/ content)
domain.com/urban-living/tempe (single page w/ content)
domain.com/urban-living/tempe/the-vale (single page w/ content)New
domain.com/urban
domain.com/urban/tempe
domain.com/urban/tempe/the-vale -
Glad it works!
-
Got it. That works. I was using Yoast Premium Redirect tools.
RewriteRule ^(.)urban-living(.)$ yoursite.com/$1urban$2 [R=301,L] the "yoursite.com/" wasn't necessary.
This did the trick. RewriteRule ^(.)urban-living(.)$ /$1urban$2 [R=301,L]
Thanks!
-
Yeah, that would be a lot of lines to add manuall., I would try the htaccess Rewrite function.
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /RewriteRule ^(.)urban-living(.)$ yoursite.com/$1urban$2 [R=301,L]</ifmodule>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} !^www.yoursite.com$ [NC]
RewriteRule ^(.*)$ yoursite.com//$1 [L,R=301]I'm not an htaccess expert, so I'm not 100% sure that it will work, if not you can check out this stack overflow thread for an explanation of the code used above.
-
I have more than a dozen... dozenS as in plural. There are 80 pages with this and want to use a single command to capture all of them, not do them individually.
Is there a way to to that?
-
Since you only have a dozen of URLs you could just do a simple 301 redirect in your .htaccess file or you can get a little more technical and do a RewriteRule that would 301 "urban-living" to "urban'
.htaccess 301 Redirect
Redirect 301/urban-living /urban
Redirect 301/urban-living/tempe /urban/tempe
Redirect 301/urban-living/tempe/the-vale /urban/tempe/the-valeHope this helps, if not, let me know if you have any questions!
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
-
Disavow links old links
We have built a lot of sites and there a few sites we no longer manage or want any association with. When I have looked at webmasters I can see 20 to 200+ odd links back to our site. The page however at source has no reference to our website. I have searched the code but there isn't anything. Is it safe to disavow these or just leave them?
Technical SEO | | Cocoonfxmedia0 -
Redirect 301 & Wild Cards
Afternoon All! Question, I am having trouble getting my head around redirects and I am wondering if someone could help me on this.... We recently changed our website and although were using the same database, were using a different URL structure. So for example... Old URL siteurl.com/products/product/moredetails/merlin.id1553.html
Technical SEO | | scottiedog
New URL siteurl.com//vertigo/dl/product.php?p=1553 As you can see the product has the same ID number, just in a different directory. What I'd like to happen is.... If you go too siteurl.com////.idXXXX.html then you are 301'd too siteurl.com//vertigo/do/product.php?p=XXXX Obviously XXXX is the ID number of the product in our database. Any thoughts? I need help! Thanks in advance.0 -
301 Redirect Best Practices
Hi SEOs, Question about ranking/redirects. If I have a particular page that is already ranking for a couple KWs in top SERPs, but know there are higher volume KWs I can optimize for should I just leave it as is or change the URL key and redirect for the time being until Google re-indexes. Example:
Technical SEO | | IceIcebaby
current URL: www.example.com/action/best-movies
new URL: www.example.com/action/best-action-movies
(the current would be ranking for "best action moves" whereas the new would include the actual "best action movies" KW) Let me know if I can clarify, thank you!0 -
Help writing a .htacess file with the correct 301 redirects
Hello I need help writing a .htaccess file that will do two things. URL match abc.com and www.abc.com to www.newabc.com except one subdomain was also changed www.abc.com/blog is now www.newabc.com/newblog everything after blog matches. Any help would greatly be appreciated. Thanks
Technical SEO | | chriistaylor0 -
Redirect link from a particular domain
Hi guys/gals, I have a few domains and blogs which I use really for a bit of fun and experimenting. One of the domains (abc.com) wasn't doing much but has a few decent links built to it. I redirected this domain to an active blog (123.com). Here's the problem: There's a particular external link to the homepage of abc.com which drives a lot of traffic but isn't relevant to the content of 123.com which it redirects to, causing a huge bounce rate from this link. Is there a way (maybe using using htaccess) that I can redirect traffic from this one link to another domain completely? I've contacted the owner of the external site but they are unable (or unwilling) to change the link. I hope I haven't lost you all but shout if you need any clarification. Thanks in advance!
Technical SEO | | Confetti_Wedding0 -
301 Link Authority 100% Transfer
Our web designer wants to change our pages from the .htm to .html extension. Would 301 redirects transfer our link juice to rankings are not harmed?
Technical SEO | | TheDude0 -
Do 301 redirects now allow most of the bad value to pass through?
I heard after the 3.2 update that most of your bad history passes though the 301 redirect.. What do you guys think out there?
Technical SEO | | Merta19801 -
When is it safe to remove 301 redirects?
I have created over 500 301 redirects in my .htaccess file, some of them are more than 2 years old now. Should I delete them? I don't like seeing the "notices" number in crawl diagnostics so high 😞
Technical SEO | | danielshaw0