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
-
What to do with old content after 301 redirect
I'm going through all our blog and FAQ pages to see which ones are performing well and which ones are competing with one another. Basically doing an SEO content clean up. Is there any SEO benefit to keeping the page published vs trashing it after you apply a 301 redirect to a better performing page?
Technical SEO | | LindsayE0 -
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 -
Will a Robots.txt 'disallow' of a directory, keep Google from seeing 301 redirects for pages/files within the directory?
Hi- I have a client that had thousands of dynamic php pages indexed by Google that shouldn't have been. He has since blocked these php pages via robots.txt disallow. Unfortunately, many of those php pages were linked to by high quality sites mulitiple times (instead of the static urls) before he put up the php 'disallow'. If we create 301 redirects for some of these php URLs that area still showing high value backlinks and send them to the correct static URLs, will Google even see these 301 redirects and pass link value to the proper static URLs? Or will the robots.txt keep Google away and we lose all these high quality backlinks? I guess the same question applies if we use the canonical tag instead of the 301. Will the robots.txt keep Google from seeing the canonical tags on the php pages? Thanks very much, V
Technical SEO | | Voodak0 -
301 or 404 old Event pages
I have a site that lists events and then removes them from the site once the date and event has passed. Is it best to let the old event page 404 or 301 back up to a subfolder that lists the current events?
Technical SEO | | Marketing_Today0 -
302 to 301 redirect
Our site has quite a few 302 redirects that really ought to be 301's. Our IT department is really busy so the question is, given that the 302's have probably been in place for years, is it worth changing them to 301's now? Thanks
Technical SEO | | Houses0 -
301 redirect blog posts from old URL to new one
I moved a wordpress blog from domain.com to domain.com/blog . I want to redirect the links in google from the old domain.com to the new one, but I also want to put a new site/application at domain.com..so I'm thinking an .htaccess 301 redirect at the root wouldn't work. Any tips?
Technical SEO | | callmeed0 -
What should be use 301 or 302 redirection for 404 pages
Please suggest which redirection we should use for 404 pages- 301 or 302. If you can elaborate it with reason then it will be highly appreciated.
Technical SEO | | koamit0 -
301 Redirect Domain or 301 Redirect Domain + Interior Pages
Hello - My company acquired another company in our industry and our IT team immediately set up the acquired companies domain name as a an alias to our site. This created a duplicate version of our website under another domain name and Google started ranking interior pages from the aliased acquired site for several top keywords that were previously held by our real site. Should we 301 redirect just the top level domain name of the acquired site to the real site or 301 redirect the top level domain name and the interior pages on the acquired site to help ensure that our real domain will take back the rankings it once had? Thanks!
Technical SEO | | Room2140