SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast rmorrow's Avatar
    Join Date
    Apr 2002
    Location
    Tacoma, WA.
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing file extensions on allpages

    I'm having a hard time finding info on putting a 301 redirect into the htaccess file for rediecting all .shtml pages to their new .html counterparts.

    There are way too many pages to redirect each one individually so is there a way to handle all of the redirects with one htaccess entry?

  2. #2
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,830
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    Try this ... it will check for a .shtml file, and if not found, will revert to .html

    # backward compatibility ruleset for
    # rewriting document.html to document.shtml
    # when and only when document.shtml exists
    # but no longer document.html
    RewriteEngine on
    # parse out basename, but remember the fact
    RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
    # rewrite to document.shtml if exists
    RewriteCond %{REQUEST_FILENAME}.shtml -f
    RewriteRule ^(.*)$ $1.shtml [S=1]
    # else reverse the previous basename cutout
    RewriteCond %{ENV:WasHTML} ^yes$
    RewriteRule ^(.*)$ $1.html

  3. #3
    SitePoint Enthusiast rmorrow's Avatar
    Join Date
    Apr 2002
    Location
    Tacoma, WA.
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure I understand this correctly, or if you understood my problem correctly...

    A lot of years ago I created my site and have not the time to update it for many years.

    I originally used inc files that required the use of an .shtml file extension - so all pages end in .shtml

    I now want to recode the site all .html extensions, so.....

    document1.shtml (etc) will become document1.html (etc)

  4. #4
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,830
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by rmorrow View Post
    I'm not sure I understand this correctly, or if you understood my problem correctly...

    A lot of years ago I created my site and have not the time to update it for many years.

    I originally used inc files that required the use of an .shtml file extension - so all pages end in .shtml

    I now want to recode the site all .html extensions, so.....

    document1.shtml (etc) will become document1.html (etc)
    Then do exactly what I suggested, but swap the .shtml and .html around


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •