How do I 301 redirect a number of pages to one page
-
I want to redirect all pages in /folder_A /folder_B to /folder_A/index.php.
Can I just write one or two lines of code to .htaccess to do that?
-
Strange.
How about something like this:
RewriteRule ^folder_B/(.*)$ /folder_A/index.php [R=301,L]I'm not an expert in RegEx or Rewrite rules, so there could be som errors in there
Good luck!
-
Its actually phpLD and I'm trying to do it with .htaccess.
For some reason the code below didn't work for me
RedirectMatch 301 /folder_A/folder_B/(.*) /folder_A/index.php
-
Nima what platform are you using?
Is it PHP or ASP? And any specific CMS?
With wordpress all you have to do is to install a redirection plugin and you are good to go... but if you have a normal php based website you have to write the following code in your .htaccess file.
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
_ Redirect 301 /oldpage2.html http://www.yoursite.com/newpage.html_
If you are on a ASP platform you have to look in to your IIS and then work accordingly.
-
Hi Nima.
Is this perhaps possible to do with a RedirectMatch? Something like:
RedirectMatch 301 /folder_A/folder_B/(.*) /folder_A/index.php
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
-
How effective are 301 redirects in passing page rank?
I have a blog which is ranking well for certain terms, and would like to repurpose it to better explain these terms it is ranking for, including updating the url to the new term the blog will be about. The plan being to 301 redirect the old url to new. In the past, I've done this with other pages, and have actually lost much of the rankings that I had earned on the original URL. What is your take on this? Maybe repurpose blog, but maintain original URL just to be on the safe side? Thanks
Technical SEO | | CitimarineMoz0 -
To 301 or not to 301?
So, to cut a long story short, on our website we have a /product page that is very similar to our homepage and doesn't really serve much of a purpose. It doesn't really fit in with the rest of the website and our directors want to get rid of it and focus our efforts on our homepage. Problem is, the /product page has a little bit of PA and links to other important pages on the website. I personally don't want to completely cut this page off. Would a 301 redirect to the homepage be a good option or would I be better off redirecting users to our course library page (Our course pages are what bring in most of our organic traffic)? Any help or other suggestions would be appreciated here! http://www.ihasco.co.uk/
Technical SEO | | iHasco1 -
301 Redirect Clarification: Images, Paramter URLs, etc.
I know that going through a site redesign it's essential to make sure that 301s are implemented for any changed URLs, but I wasn't sure if this was the same for the images on the page and the parameter URLs that are created by marketing campaigns - do those URLs also need to be 301 redirected? For example, this URL: www.mysite.com/32-inch-round-aluminum-table/ Could have a parameter at: www.mysite.com/32-inch-round-aluminum-table/?utm_source=twitterfeed&utm_medium=twitter&utm_campaign=Social%3A+My_Site And an image at: www.mysite.com/images/32-inch-round-aluminum-table.jpg Would the first two URLs mentioned need to be redirected to the new URL, and the image redirected to the new image URL? Thanks for the help.
Technical SEO | | eTundra0 -
Double 301 redirect
Hi together, due to some technical reasons I have redirect (301) an existing link two times. Example: www.mydomain.com/root/site.html > 301 > www.mydomain.com/site.html > 301 www.mydomain.com/site_new.html Is there anybody how has got some experience like doing a double redirect? What about link juice? Best regards Steffen
Technical SEO | | steffen_0 -
301 redirecting some pages directly, and the rest to a single page
I've read through the Redirect guide here already but can't get this down in my .htaccess I want to redirect some pages specifically (/contactinfo.html to the new /contact.php) And I want all other pages (not all have equivalent pages on the new site) to redirect to my new (index.php) homepage. How can I set it up so that some specific pages redirect directly, and all others go to one page? I already have the specific oldpage.html -> newpage.php redirects in place, just need to figure out the broad one for everything else.
Technical SEO | | RyanWhitney150 -
How do 301 redirects affect rankings?
Scenario: example.com/red-shoes gets 301 redirected to example.com/brown-boots because we have stopped selling red shoes and now only sell brown boots (which is a fairly new page with no authority). the red-shoes page ranked well for "red shoes" and "footwear". Will Google still index and show the red-shoes url in the SERPs? Will the "red shoes" and "footwear" keywords still rank well? Or does the redirected/new boots page need to properly support these keywords? The boots page has inherited the juice from the shoes page, but how does it help the boots page rank well? Only for keywords that both pages targeted, like a general "footwear" type keyword? Thanks in advance!
Technical SEO | | akim260 -
301 redirects
Hi Guys, Question,
Technical SEO | | VividLime
Lets say I have a page oldfile.php at position #2 then set-up a redirection in the following way 100 incoming external links--> oldfile.php [301 to] newfile.php Google comes along and updates its index to newfile.php and ranking of newfile.php remains at position #2. Everything is good. Lets say in 5months, I come along and delete oldfile.php so we have
100 incoming external links--> deleted(oldfile.php) or 100 incoming external links-->404 error. |||| newfile.php Do I then loose the rankings on newfile.php. My thinking is that now that all the external links now point to a page not found, newfile.php should loose rankings Am I correct in my assumption?0 -
301 redirects inside sitemaps
I am in the process of trying to get google to follow a large number of old links on site A to site B. Currently I have 301 redirects as well a cross domain canonical tags in place. My issue is that Google is not following the links from site A to site B since the links no longer exist in site A. I went ahead and added the old links from site A into site A's sitemap. Unfortunately Google is returning this message inside webmaster tools: When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL. However I do not understand how adding the redirected links from site B to the sitemap in site A will remove the old links. Obviously Google can see the 301 redirect and the canonical tag but this isn't defined in the sitemap as a direct correlation between site A and B. Am I missing something here?
Technical SEO | | jmsobe0