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
-
Redirect 301 to homepage
Hello there, I have some low quality pages in my site, can I redirect 301 them to my homepage? My website is: https://idanito.com idanito.com
Technical SEO | | dannybaldwin0 -
301 Redirect Url Within a Canonical Tag
So this might sounds like a silly question... A client of mine has a duplicate content issue which will be fixed using canonical tags. We are also providing them with an updated URL structure meaning rwe will be having to do lots of 301 redirects. The URL structure is a much larger task that than the duplicate content so i planned to set up the canonicals first. Then it occurred to me id be updating the canonical tags with the urls from the old structure which brings me to my question. Will the canonical tags with the old urls redirect credit to the new urls with the 301? Or should i just wait until we have the new url structure in place and use these new urls in the canonicals? Thanks!
Technical SEO | | NickG-1230 -
How do I redirect the Author archive page in Wordpress?
If you do a search for my name on Google, the first result is the author archive page of my Wordpress blog. I would like to redirect the author page to my "about me" page but cannot add a 301 as the author page is created dynamically in Wordpress. Anyone know how I can do this?
Technical SEO | | richdan0 -
404 to 301 redirects is there a limit?
Hi We've just updated our website and have binned out alot of old thin content which has no value even if re written. We have a lot of 404 error on WMT and I am in the process of doing 301 redirects on them. Is there a limit to the number of 301 the site should have?
Technical SEO | | Cocoonfxmedia0 -
Using 302s to redirect pages returning in 6 months
We are doing a 2-phase site redesign (in order to meet a deadline). An entire section of the site will not be available in the first phase, but will come back in 6 months. The question is, do we use 301s or 302s for those pages that will be coming back in 6 months? Is there a time limit on what is considered "temporary"? thanks in advance!
Technical SEO | | Max_B0 -
Redirect them to some other related pages in your website
dear sir, i found 404 errors in my google adsense account as well google webmaster tool. how can i escape from these errors. and also tell me why can i increase google click rate. my google rate is so low.
Technical SEO | | learningall0 -
Where does Wordpress store the 301 redirects?
Hi, I've just created a campaign for my new wordpress blog and found 11 301 redirects which I was not aware of. It looks like wordpress has created them automatically. Does any one know how wordpress handles this issues or where are they stored so I can delete them? They are of no use for me. 9 of these redirects point to the same url with an added '/' and are in pages 1 is on a post. I've been changing the permalink and some urls several times and maybe one of these times the Wordpress has automatically created the 301 redirect. But why? I do not want to keep the old url. the last redirect is very strange it goes from http://www.mydomain.com/folder to http://www.mydomain.com where folder is the folder where I installed wordpress. But again, I want no one to type the url with the folder name or even know this folder exists. Any comment on this would be greatly appreciated. Thanks a lot, David
Technical SEO | | dballari0 -
Looking for some help adding a 301 redirect for my Site
Hi there, I am trying to eliminate the 'www' using a 301 redirect script as I have duplicate page titles for both versions (with and without the 'www') I checked the page authority and found the pages without the 'www' to be ranked higher. For this reason I believe it would be wise to go for this option. I have an .htaccess file, all I need is the code and I should be ok 🙂 Thanks!
Technical SEO | | debeenus0