Sitewide 301 Redirect

I am looking to redirect a 301 server. Source site over 15 years old! I understand the concept of creating a .htaccess file with code:

redirect 301 "/old/old.htm" http://www.you.com/new.html 

However, will it redirect every page of the old site? or just a single page. How to get redirects from all over the site?

+4
source share
5 answers

I have rewriting in .htaccess (apache rewrite mod mode is enabled), all pages from the old site http://www.old.com and http://www.old.com/site/index.php? .... redirect to a new site http://www.new.com or http://www.new.com/website/index.php? ... (note that / site / and / website / are different names)

pages from the old site https://www.old.com (note that s to https: //) is redirected perfectly, but pages from https://www.old.com/site/index.php? ... no, they get 404 error

since the old site is no longer protected by https://www.old.com or https://www.old.com/site/index.php? ... there really is more, but https://www.old.com is redirected, and /site/index.php? ... the added one is not redirected, and instead 404 error

+3
source

Be careful with 301 301 redirects to move content.

eg. the content about making the cake was here /makeacake.html now / cakes / making-a-cake.html.

what I would recommend is to find the pages that most of your applications come to, and redirect those pages to new relevant pages / sections and just delete the rest and add a 404 error page that tells them that the old content has been moved.

You can also use the goggle webmasters to remove pages from this index.

+2
source

Assuming that the old pages no longer exist (will cause 404 errors), you can do the following: you redirect all pages that no longer exist to the start page. (As indicated in the comments below.)

This is an updated .htaccess code that you can use to make this happen. The first RewriteCond checks if the requested path is a file, the second checks if it is a directory. After that, you are redirected to the start page or to any other page.

http://www.example.com/i/am/an/old/page.html or http://www.example.com/i/am/a/different/old/page.html will be redirected to http://www.example.com/

 RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . / [R=301,L] 
+1
source

The best way to redirect the entire site is to forward the domain through your web server (or web host ... most of them have an option on the control panel).

Domain forwarding is much more efficient than sending 301 redirects back to the client.

0
source

I understand correctly that your site is on the same domain name, but have you changed it structurally?
That way, you have the loading of old page URLs that are now changed to new URLs (but in the same domain).


For example, you could have:
www.yourdomain.com/about-us/history.htm
which has now become
www.yourdomain.com/our-history.htm


If so, you will most likely need to configure many 301 redirect rules. This does not necessarily mean that you need to configure one rule for each individual page, since you can use RegEx to search for pattern changes in the URL structure. As an example of the scale, I recently installed a htaccess file of 301 redirects for a site with less than 600 URLs changed. At the end there were 70 301 redirect rules.


This is not necessarily a little work, but it is doable. It’s worth maintaining your SEO rankings.

0
source

Source: https://habr.com/ru/post/1334381/


All Articles