For custom directives you can use .htaccess file because is works with apache server configuration so this is best way to redirect old URLs to new one to get rid from 404(Page not found) Error . 301 redirect htaccess takes very less time to redirect your old page to new page and also SEO friendly because using this technique indexed content by search engines treated as same. Url Canonicalization means if your site have same content on different-2 URLs then Search Engines treated this as duplicate content that is not good for SEO prospects.
You need to redirect your old page to new page and 301 redirect is best for doing this.
If you are able to access your site with or without www then pick one URL pattern with www(www.yoursite.com) or without www(yoursite.com).
#Redirect non-www to www :
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]#Redirect www to non-www :
RewriteEngine On RewriteBase / RewriteCond % ^www.yoursite.com [NC] RewriteRule ^(.*)$ http://yoursite.com/$1 [L,R=301]
#Redirect directory to subdomain
RedirectMatch 301 ^/directory_name/(.*)$ http://subdomain.yoursite.com/$1
#Redirect specific page
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
#Redirect an entire website
Redirect 301 / http://www.yournewsite.com/
#Redirect single page to directory
Redirect 301 /oldpage.html http://www.yoursite.com/directory_name/
301 redirect htaccess methods helps you to get rid from 404 error from old URLs that has been changed and increase your site SEO level.