The Apache Web Server provides a couple ways to issue 301 Redirects from within .htaccess or httpd.conf files.
When do you need a 301 Redirect?
Using mod_alias we have access to these directives: Redirect, RedirectMatch, RedirectPermanent, and RedirectTemp. You only need to know that RedirectMatch allows pattern matching and Redirect is only for a single file.
Redirect
Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html https://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost/ Redirect 301 /2007/phpbb/sending-post-form-data-with-php-curl.html https://www.askapache.com/htaccess/sending-post-form-data-with-php-curl/ Redirect 301 /htaccess.txt /wp-content/uploads/p/htaccess.txt Redirect 301 /2007/webmaster/php-and-ajax-shell-console.html https://www.askapache.com/tools/php-and-ajax-shell-console/ Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html https://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost/
RedirectMatch
RedirectMatch 301 ^/(.*).htm$ https://www.askapache.com/$1.html RedirectMatch 301 ^/200([0-9])/([^01])(.*)$ https://www.askapache.com/$2$3 RedirectMatch 301 ^/category/(.*)$ https://www.askapache.com/$1 RedirectMatch 301 ^/(.*)/htaccesselite-ultimate-htaccess-article.html(.*) https://www.askapache.com/htaccess/ RedirectMatch 301 ^/(.*).html/1/(.*) https://www.askapache.com/$1.html$2 RedirectMatch 301 ^/manual/(.*)$ http://www.php.net/manual/$1 RedirectMatch 301 ^/dreamweaver/(.*)$ https://www.askapache.com/tools/$1 RedirectMatch 301 ^/z/(.*)$ https://www.askapache.com/s/s.askapache.net/$1
mod_rewrite is a powerful Apache module, and you should read more about it before you cause a problem.
RewriteRule .* https://www.askapache.com/$1 [R=301,L] RewriteRule ^(.*).html([^c]+)comment-(.+)$ https://www.askapache.com/$1.html#comment-$3 [R=301,L,NE]