PHP to HTML mod rewrite solution?

Discussion in 'Apache' started by Seobiznezz, Jun 21, 2006.

  1. #1
    was wondering if someone knew how to change .php to .html through a mod rewrite as we want to change the site to .php but keep all the cached pages as .html

    Anything simple would be best. Don't want to have to start over with .php pages in the SERPS.
     
    Seobiznezz, Jun 21, 2006 IP
  2. mjewel

    mjewel Prominent Member

    Messages:
    6,693
    Likes Received:
    514
    Best Answers:
    0
    Trophy Points:
    360
    #2
    Why not code the pages in php but keep them all with the html extension?

    RewriteRule ^(.*)\.html$ $1.php [L]
     
    mjewel, Jun 21, 2006 IP
  3. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #3
    We use this for *.phtml pages:

    
    RewriteEngine on
    
    RewriteRule   ^(.*)\.html$              $1      [C,E=WasHTML:yes]
    
    #   rewrite to document.phtml if exists
    RewriteCond   %{REQUEST_FILENAME}.phtml -f
    RewriteRule   ^(.*)$ $1.phtml                   [S=1]
    
    #   else reverse the previous basename cutout
    RewriteCond   %{ENV:WasHTML}            ^yes$
    RewriteRule   ^(.*)$ $1.html
    
    Code (markup):
    This allows us to keep the pages as *.phtml locally, but show *.html to the world.
     
    clancey, Jun 21, 2006 IP
  4. Seobiznezz

    Seobiznezz Peon

    Messages:
    496
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for the responses
     
    Seobiznezz, Jun 22, 2006 IP
  5. sunday

    sunday Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Or just try:

    AddType application/x-httpd-php .php .html
     
    sunday, Jun 30, 2006 IP