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.

Mod_ReWrite

Discussion in 'Apache' started by mnemtsas, Nov 28, 2004.

  1. #1
    Hi,

    I'm in the process of swapping over from static HTML to PHP. From what I understand to not lose all of the hard earned SEO I've done I need to rewrite a request for foo.htm to foo.php . After a while on Google (I'm obviously using the wrong search terms) I cannot for the life of me figger out how to do this.

    Can someone lend a dummy at hand?

    I want to rewrite foo.htm to foo.php so that someone who requests foo.htm is actually served foo.php.

    Cheers,

    Mark
     
    mnemtsas, Nov 28, 2004 IP
  2. quadcity

    quadcity Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello Mark.
    I think you might be able to configure your server to parse .htm files as well as .php files. (Although I could be thinking of another scripting environment.)

    Hopefully somebody here can give a more authoritative answer.
     
    quadcity, Nov 28, 2004 IP
  3. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Quadcity,

    Yes that's exactly what I need to do, I've managed to find the right combination of words to type into google and come up with the following:

    Add another apache type using:

    AddType application/x-httpd-php .html
    AddType application/x-httpd-php .htm

    in my .htaccess files. This means anything in a html file is parsed with php.

    Cheers,
     
    mnemtsas, Nov 28, 2004 IP
  4. billion

    billion G.E.M.

    Messages:
    423
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    140
    #4
    This is what I use in my .htaccess file:

    RewriteEngine on
    RewriteRule ^(.+)\.html $1.php [QSA]

    It will probably work for you too. Keep in mind that it effects the directory you put it in + directories below this directory.

    If you use .htm make sure to change .html to .htm in the code above. :)
     
    billion, Nov 29, 2004 IP