Web Professionals use mod_rewrite to issue 301 and 302 Redirects for Search Engines. Sometimes you may not have mod_rewrite.c or you want an alternative redirect method. Using mod_alias RedirectMatch you can use REGEX in Redirect commands!


| .htaccess Tutorial Index |


SEO Search Engine Friendly Redirects without mod_rewrite

SEO 301 Redirect Single File

Redirect 301 /d/file.html /ddd/file.html

Redirect Home to new Domain

Redirect 301 / http://www.htaccesselite.com

301 Redirect multiple files

RedirectMatch 301 /blog(.*) /$1

Redirect Entire site to single file

Note: This is a 302 (temporary)redirect because its meant to point to a temporarily offline file.

RedirectMatch 302 ^/ /temporary-offline.html

Putting it all together

301 and 302 Redirects

Redirect 301 /security/rigging-the-dreamhost-site-of-the-month-contest.html http://www.askapache.com/dreamhost/rigging-the-dreamhost-site-of-the-month-contest.html
Redirect 301 /htaccess/speed-up-the-apache-web-server-with-configuration-hacks.html http://www.askapache.com/htaccess/apache-web-server-speed-configuration-hacks.html
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 http://z.askapache.com/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
Redirect 301 /seo/tailrankcom-robot.html http://www.askapache.com/seo/tailrank-robot.html
Redirect 301 /instruct-search-engines-to-come-back-to-site-after-you-finish-working-on-it.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /htaccess/instruct-search-engines-to-come-back-to-site-after-you-finish-working-on-it.html http://www.askapache.com/htaccess/503-service-temporarily-unavailable.html
Redirect 301 /webmaster/lft-traceroute-tool.html http://www.askapache.com/tools/lft-traceroute-tool.html
# 302 Temporary
Redirect 302 /apachesearch/ http://google.com/coop/cse?cx=002660089121042511758%3Akk7rwc2gx0i

RedirectMatch with wildcards

RedirectMatch 301 ^/wp-content/uploads/p/(.*)$ http://z.askapache.com/p/$1
RedirectMatch 301 ^/(.*)apache-htaccess.html/2/(.*)$ http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/3/(.*)$ http://www.askapache.com/htaccess/php-htaccess-tips-and-tricks.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/4/(.*)$ http://www.askapache.com/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/5/(.*)$ http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/6/(.*)$ http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/7/(.*)$ http://www.askapache.com/htaccess/apache-authentication-in-htaccess.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/8/(.*)$ http://www.askapache.com/htaccess/security-with-apache-htaccess.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/9/(.*)$ http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html$2
RedirectMatch 301 ^/(.*)apache-htaccess.html/10/#htaccess-glossary http://www.askapache.com/htaccess/htaccess-for-webmasters.html#htaccess-glossary
RedirectMatch 301 ^/(.*)apache-htaccess.html/10/(.*)$ http://www.askapache.com/htaccess/apache-variable-fun-in-htaccess.html$2
RedirectMatch 301 ^/(.*)\.htm$ http://www.askapache.com/$1.html
RedirectMatch 301 ^/200([0-9])/([^01])(.*)$ http://www.askapache.com/$2$3
RedirectMatch 301 ^/(.*)/htaccesselite-ultimate-htaccess-article.html(.*) http://www.askapache.com/htaccess/apache-htaccess.html
RedirectMatch 301 ^/(.*)\.html/1/(.*) http://www.askapache.com/$1.html$2
RedirectMatch 301 ^/category/(.+)$ http://www.askapache.com/$1

Redirecting using the following directives is done using the module mod_alias. RedirectMatch, RedirectPermanent, RedirectTemp, Redirect


htaccess Guide Sections

| .htaccess Tutorial Index |



Related Articles