#1
  1. No Profile Picture
    Contributing User
    SEO Chat Discoverer (100 - 499 posts)

    Join Date
    Oct 2004
    Posts
    391
    Rep Power
    10

    Redirect all pages to index.html with .htaccess


    How do I redirect all pages on my site to index.html via the .htaccess-file?
  2. #2
  3. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Nov 2005
    Posts
    13
    Rep Power
    0

    Post


    To redirect ALL files on your domain use this in your .htaccess file if you are on a unix web server:

    redirectMatch 301 ^(.*)$ http://www.domain.com
    redirectMatch permanent ^(.*)$ http://www.domain.com

    You can also use one of these in your .htaccess file:

    redirect 301 /index.html http://www.domain.com/index.html
    redirect permanent /index.html http://www.domain.com/index.html
    redirectpermanent /index.html http://www.domain.com/index.html

    This will redirect "index.html" to another domain using a 301-Moved permanently redirect.

    2. If you need to redirect http://mysite.com to http://www.mysite.com and you've got mod_rewrite enabled on your server you can put this in your .htaccess file:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*).htm$ $1.html [R=301,L]

    or this:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

    Tip: Use your full URL (ie http://www.domain.com) when obtaining incoming links to your site. Also use your full URL for the internal linking of your site.

    3. If you want to redirect your .htm pages to .php pages and you've got mod_rewrite enabled on your server you can put this in your .htaccess file:

    RewriteEngine on
    RewriteBase /
    RewriteRule (.*).htm$ /$1.php

    4. If you wish to redirect your .html or .htm pages to .shtml pages because you are using Server Side Includes (SSI) add this code to your .htaccess file:

    AddType text/html .shtml
    AddHandler server-parsed .shtml .html .htm
    Options Indexes FollowSymLinks Includes
    DirectoryIndex index.shtml index.html
  4. #3
  5. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Jun 2004
    Posts
    16
    Rep Power
    0
    Thats a good help.

    What if I want to do this redirect all files from http://www.mysite.com/forum/ (so everything in this directory) to http://www.mysite.com/forum-now-closed.htm

    So basically to a full redirect of this directory to one single message display page?

    How would this be done?

    Any help would be great thanks. I have a good head start from your info above so if anyone beats me to it that would be great. Thanks...
  6. #4
  7. Contributing User
    SEO Chat Good Citizen (1000 - 1499 posts)

    Join Date
    May 2004
    Location
    Brighton
    Posts
    1,129
    Rep Power
    18
    It's probably easier just to remove all your pages and have a custom 404 page that says, sorry now closed for business.

    Edit: that probably won't work for your home page, so also replicate your 'closed' page as index.htm or whatever.
    Last edited by john alphaone; Sep 8th, 2006 at 01:30 AM.
    Sussex Barn Dance
    The Hokey Cokey - is that really what it's all about?

Similar Threads

  1. How does google rank 301 redirect pages?
    By sparknote_s in forum Search Engine Optimization
    Replies: 0
    Last Post: Jul 26th, 2005, 12:49 PM
  2. More Content Pages Than Keywords
    By Robert Paulson in forum Search Engine Optimization
    Replies: 4
    Last Post: Apr 5th, 2005, 07:22 PM
  3. redirect to affiliate in cpanel or .htaccess?
    By preikarm in forum Web Design, Coding and Programming
    Replies: 1
    Last Post: Mar 31st, 2005, 05:04 AM
  4. share: doing redirect with .htaccess
    By Sam Tang in forum Google Optimization
    Replies: 5
    Last Post: Dec 6th, 2004, 04:45 PM

IMN logo majestic logo threadwatch logo seochat tools logo