Apache中301转向有很多办法,下面列举其中几例:
301 Redirects using Redirect(用Redirect命令实现)
Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html http://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost.html Redirect 301 /2007/phpbb/sending-post-form-data-with-php-curl.html http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html Redirect 301 /htaccess.txt /wp-content/uploads/p/htaccess.txt Redirect 301 /2007/webmaster/php-and-ajax-shell-console.html http://www.askapache.com/tools/php-and-ajax-shell-console.html Redirect 301 /2007/webmaster/custom-phpini-with-fastcgi-on-dreamhost.html http://www.askapache.com/dreamhost/custom-phpini-with-fastcgi-on-dreamhost.html
301 Redirects using RedirectMatch(用RedirectMatch实现)
RedirectMatch 301 ^/(.*)\.htm$ http://www.askapache.com/$1.html RedirectMatch 301 ^/200([0-9])/([^01])(.*)$ http://www.askapache.com/$2$3 RedirectMatch 301 ^/category/(.*)$ http://www.askapache.com/$1 RedirectMatch 301 ^/(.*)/htaccesselite-ultimate-htaccess-article.html(.*) http://www.askapache.com/htaccess/htaccess.html RedirectMatch 301 ^/(.*)\.html/1/(.*) http://www.askapache.com/$1.html$2 RedirectMatch 301 ^/manual/(.*)$ http://www.php.net/manual/$1 RedirectMatch 301 ^/dreamweaver/(.*)$ http://www.askapache.com/tools/$1 RedirectMatch 301 ^/z/(.*)$ http://static.askapache.com/$1
当然,还有通过htaccess文件来实现,比如
RewriteRule ^(x*)$ http://www.zuosha.net/$1 [L,R=301]
实际中还有更多的写法,可以参见http://www.askapache.com/htaccess/301-redirect-with-mod_rewrite-or-redirectmatch.html以及http://www.askapache.info//2.3/mod/mod_alias.html#redirectmatch等页面。
实用技巧->301, apache, htaccess, RedirectMatch
