1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

simple mod rewrite .php to .html

Discussion in 'Apache' started by Swordfish, Jan 2, 2006.

  1. #1
    Swordfish, Jan 2, 2006 IP
  2. LGRComp

    LGRComp Well-Known Member

    Messages:
    516
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    195
    #2
    Try this:

    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)\.php$ $1.html [R=permanent]
     
    LGRComp, Jan 2, 2006 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    The .html URL would need to work.

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)\.html$ $1.php [L]

    And you can't have both a mod_rewrite and 301 redirect for the same URLs because it'll loop. Apache says...I want .php, no it's .html, no .php, no....grrrr!!!! :D
     
    Nintendo, Jan 2, 2006 IP
  4. mdvaldosta

    mdvaldosta Peon

    Messages:
    4,079
    Likes Received:
    362
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I will say though, that theirs no seo reasoning behind changing from php to html, I don't know why people worry with that. Mod_rewrite is only worth it to get url's without multiple variables.
     
    mdvaldosta, Jan 2, 2006 IP
  5. Lisper

    Lisper Guest

    Messages:
    86
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Or to not show file extensions at all. They are of no value to the visitor, make the url longer (i like short urls) and when you want to change from one implementation to the other you won't have to change all your urls and potentially lose incoming links, break visitor's bookmarks etc. :)

    Haven't been able yet to remove aspx file extensions though. MultiViews works great for php files but I think I'll have to use mod_rewrite for aspx files.
     
    Lisper, Jan 3, 2006 IP
  6. MaxPowers

    MaxPowers Peon

    Messages:
    261
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Or you can simply name them .html from the start and allow HTML files through your PHP interpreter

    AddType application/x-httpd-php htm html php
    AddHandler application/x-httpd-php .htm .html
     
    MaxPowers, Jan 7, 2006 IP
  7. abstractart

    abstractart Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    where should these commands be?
     
    abstractart, Nov 28, 2008 IP
  8. snvc

    snvc Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8

    Be in your .htaccess
     
    snvc, Nov 28, 2008 IP