FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home » Htaccess » SEO Redirects without mod_rewrite

SEO Redirects without mod_rewrite

SEO Redirects without mod_rewrite

April 10th, 2007

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!


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 /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
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://static.askapache.com/p/$1
RedirectMatch 301 ^/(.*)htaccess.html/2/(.*)$ http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html$2
RedirectMatch 301 ^/(.*)htaccess.html/3/(.*)$ http://www.askapache.com/htaccess/php-htaccess-tips-and-tricks.html$2
RedirectMatch 301 ^/(.*)htaccess.html/4/(.*)$ http://www.askapache.com/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite.html$2
RedirectMatch 301 ^/(.*)htaccess.html/5/(.*)$ http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html$2
RedirectMatch 301 ^/(.*)htaccess.html/6/(.*)$ http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html$2
RedirectMatch 301 ^/(.*)htaccess.html/7/(.*)$ http://www.askapache.com/htaccess/apache-authentication-in-htaccess.html$2
RedirectMatch 301 ^/(.*)htaccess.html/8/(.*)$ http://www.askapache.com/htaccess/security-with-htaccess.html$2
RedirectMatch 301 ^/(.*)htaccess.html/9/(.*)$ http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html$2
RedirectMatch 301 ^/(.*)htaccess.html/10/#htaccess-glossary http://www.askapache.com/htaccess/htaccess-for-webmasters.html#htaccess-glossary
RedirectMatch 301 ^/(.*)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/htaccess.html
RedirectMatch 301 ^/(.*)\.html/1/(.*) http://www.askapache.com/$1.html$2
RedirectMatch 301 ^/category/(.+)$ http://www.askapache.com/$1

Redirecting To Trigger Errors

Redirect 400 /seo/400
Redirect 401 /seo/401
Redirect 402 /seo/402
Redirect 403 /seo/403
Redirect 404 /index.php?error=404
Redirect 405 /seo/405
Redirect 406 /seo/406
Redirect 407 /seo/407
Redirect 408 /seo/408
Redirect 409 /seo/409
Redirect 410 /seo/410
Redirect 411 /seo/411
Redirect 412 /seo/412
Redirect 413 /seo/413
Redirect 414 /seo/414
Redirect 415 /seo/415
Redirect 416 /seo/416
Redirect 417 /seo/417
Redirect 418 /seo/418
Redirect 419 /seo/419
Redirect 420 /seo/420
Redirect 421 /seo/421
Redirect 422 /seo/422
Redirect 423 /seo/423
Redirect 424 /seo/424
Redirect 425 /seo/425
Redirect 426 /seo/426
Redirect 500 /seo/500
Redirect 501 /seo/501
Redirect 502 /seo/502
Redirect 503 /seo/503
Redirect 504 /seo/504
Redirect 505 /seo/505
Redirect 506 /seo/506
Redirect 507 /seo/507
Redirect 508 /seo/508
Redirect 509 /seo/509
Redirect 510 /seo/510

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


htaccess Guide Sections

| .htaccess Tutorial Index |



Please Comment!

Your email address is not saved.

Reader Comments

  1. seb ~March 20, 2012 @ 10:12 am

    Redirect entire site to a single file:

    RedirectMatch 302 ^/ /temporary-offline.html

    is bullshit as this will lead to an endless loop trying to load that file

  2. Rafael ~January 25, 2011 @ 3:58 pm

    I changed my permalink structure.

    All links we spreaded will have a 301. But the permalink structure was changed to ignore month and links does not work anymore. Before, it was /%monthnum%-%year%/%postname%-%postid% like /08-2010/name.xx for a post made in august of 2010, and now it is just /%year%/%postname%-%postid%.html -> we removed month and added html to the end.

    What do I do to redirect to the correct page? What do I put after the rule? I mean...

    RedirectMatch 301 ^/index.php/01-(.*)/ to ?.html
    RedirectMatch 301 ^/index.php/02-(.*)/  ?.html
    RedirectMatch 301 ^/index.php/03-(.*)/  ?.html
    ...
    RedirectMatch 301 ^/index.php/12-(.*) /  ?

    What do I put instead of the question marks?
    Please, give me a light!

  3. Thomas ~October 29, 2010 @ 12:34 am

    A great tool for checking your redirect and server status codes. Thanks for the great article.

  4. Pingback: Issue 6: Redirecting your site visitors: How to give them a safe, happy landing | SEO MixTour - a free SEO newsletter by Web CEO
  5. evo3cx ~August 10, 2010 @ 5:18 am

    “Redirect Entire site to single file” section, your code is doing an infinite redirection.

    I tried to edit it to avoid the circle. I know that changing it to an external URL solves the problem, but is there another way to do that?

  6. İyinet ~July 16, 2010 @ 5:03 am

    Very informative post how to use a 301 redirect, Thanks. But is it really usefull for crawling googlebot?

  7. Aben ~April 2, 2010 @ 12:39 pm

    Hmm, I couldn't make the SEO 301 Redirect Single File work in my htaccess.

  8. samad ~March 20, 2010 @ 9:50 pm

    Good work! thanks for the useful tips on php mod_rewrite..!

  9. Free WEB ~November 9, 2009 @ 4:38 am

    thanks for the tip..... Web Hosting with Php Sendmail Curl Fopen Allow and Php mod_rewrite enable.

  10. SEO Wanna Be ~November 3, 2009 @ 10:25 pm

    Hi your post is amazing, It's incredible, I learned a lot about SEO and Man, this thing's getting better and better as I learn more about internet marketing. Also as part of my ongoing mission to find the absolute best tools to make money, this is without a doubt at the top of my list. Everything happened so fast!

  11. nur ~September 16, 2009 @ 8:19 pm

    thanks, I made my site 301 redirect using this tips. the best post on redirection I found in net.

  12. facebookguru ~September 4, 2009 @ 7:31 am

    Very informative and helpful, before I read this post I was totally confused how to use a 301 redirect, keep it up good work. Thanks

  13. Tia ~July 6, 2009 @ 11:16 pm

    I have all my websites 1700 pages ending in .html. How do I redirect them to remove that?

    for example

    /pp.html to /pp/
  14. Pedro Cunha ~October 31, 2008 @ 5:30 pm

    @AJ: I think I've found the solution:

    RedirectMatch 301 ^/old-(.*) /

    This will make all the files located at /old-* redirect to / .

    Hope I've solved the problem! ;)

  15. Pedro Cunha ~October 31, 2008 @ 4:05 pm

    In the "Redirect Entire site to single file" section, your code is doing an infinite redirection.

    I tried to edit it to avoid the circle. I know that changing it to an external URL solves the problem, but is there another way to do that?

  16. AJ ~October 7, 2008 @ 6:13 pm

    I really like your site - great tips!

    I'm trying to 301 redirect an entire site to the index.html (so all of the links going to old interior pages would still keep passing PR to the index page) but am getting an error when I'm using the following code

    RewriteRule /.* http://www.mysite.com/ [R=301,L]

    I want to get it to where when anyone (or any search engine) comes to any old page (mysite.com/old-page.html) they're 301 redirected to the new home page. Do you know what code I should be using in my htaccess to accomplish this?

    Thanks so much!

  17. sg ~December 17, 2007 @ 1:48 pm

    Hi,
    I'm trying to 301 redirect a url that contains a question mark, but I can't get it to view the ? literal. I'm assuming that's the issue.

    Here's what I've tried, but hasn't worked.

    URL I want redirected -http://www.mysite.com/foo/?section=page

    RedirectMatch 301 ^/foo/\?section=page$ http://www.mysite.com/foo/
    and
    RedirectMatch 301 ^/foo/*section=page$ http://www.mysite.com/foo/
    and
    RedirectMatch 301 ^/foo/(.*)section=page$ http://www.mysite.com/foo/

    Any ideas of what I'm doing wrong. Thanks!

  18. AskApache ~November 1, 2007 @ 11:04 pm

    @ D K

    RedirectMatch 301 ^/level\.itml/icOid/184$ http://www.mysite.com/noticemykeyword
  19. D K ~October 25, 2007 @ 1:45 pm

    Hi,

    I'm trying to figure out the syntax for an .htaccess line entry that would
    perform the following redirection

    mysite.com/level.itml/icOid/184 mysite.com/noticemykeyword
    I thought this would work :

    Redirect 301 /level\.itml/icOid/184 http://www.mysite.com/noticemykeyword

    but it doesn't.
    I'll keep reading and experimenting, but I'd really appreciate any suggestions or tips.

    Thanks,


It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

Site Map | Contact Webmaster | Glossary | License and Disclaimer | Terms of Service |

↑ TOPMain