I need a modrewrite done

Discussion in 'Programming' started by Blonde Jon, Sep 13, 2007.

  1. #1
    Hello, I'm willing to pay $10 via Paypal to who ever can make a modrewrite for me.

    I currently have .html pages. For ease of editing I'm going to create php pages, but I need search engines to see these php pages as html pages. My URLs need to go from:

    site.com/aboutus.php to site.com/aboutus.html

    Thanks!
     
    Blonde Jon, Sep 13, 2007 IP
  2. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
  3. Blonde Jon

    Blonde Jon Active Member Affiliate Manager

    Messages:
    745
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Blonde Jon, Sep 13, 2007 IP
  4. ErectADirectory

    ErectADirectory Guest

    Messages:
    656
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    What BlondJon is trying to do is a very simple server side trick that allows web site owners to change their pages from static to dynamic (html to php) without the # of indexed pages or SERP results changing one bit.

    There are 2 important points to why he is doing this.

    1. by making your site php (or similar) you open the door to easy editing. If you had a site built a while ago, there is a good chance that the pages were created in html therefore offer no dynamic features to it at all. Bottom line is that editing any part of your site becomes a pain in the ass because you have to change 50 pages instead of just one line of code.

    2. Over time, search engines will have all your pages indexed. If you all of a sudden change your entire site to .php extensions you basically get to start from scratch (pages won't be indexed, inbound links are all broken, etc.). Basically aboutUs.html & aboutUs.php are totally different pages in a bots eyes, even though they would have the same content. He also avoids any duplicate content penalties (though it would be small since on the same site).

    Sorry for the lengthy explanation for the benefit of the readers, but Jon has obviously put a lot of though into the upkeep of his site and I want to make sure that the reasons behind this move are clear. Jon has effectively changed his entire page structure and enhanced his ability to regularly update his site. All the while having 0 clues of this left behind to confuse slurp, googlebot and the rest of the gang.

    Well done Jon & best of luck.
     
    ErectADirectory, Sep 14, 2007 IP
    Blonde Jon likes this.
  5. Saberu

    Saberu Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    This is what you want to do, make the php pages using GET values for each page then do mod rewrite from the html to the php page with get value inserted.

    RewriteRule ^index.html$ /index.php?menu=index [R=301]
    RewriteRule ^index.html/?$ /index.php?menu=index

    There might be a cleverer way to do this..

    RewriteRule ^([^/]+).html$ /index.php?menu=$1 [R=301]
    RewriteRule ^([^/]+).html/?$ /index.php?menu=$1

    So it would rewrite anything that is a html page to index.php?menu=htmlpagename (without the .html extension)
     
    Saberu, Sep 14, 2007 IP
  6. Blonde Jon

    Blonde Jon Active Member Affiliate Manager

    Messages:
    745
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    ErectADirectory took care of it for me. Thanks for the help ErectADirectory!
     
    Blonde Jon, Sep 14, 2007 IP
  7. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    EDIT: sorry, I keep tabs open for far too long before replying and missed that message :p

    Jon, first, create a file named ".htaccess" in the web root, e.g. /public_html/

    Method 1: Rewrite .html to .php

    Add this to .htaccess:

    RedirectEngine On
    RewriteCond %{REQUEST_URI} (.+)\.php
    RewriteRule . %1.html [R=301,L]
    RewriteRule (.+)\.html $1.php [L]

    Method 2: parse .html as .php

    Go to your file manager, rename all files from *.php to *.html
    Add this to .htaccess:

    RemoveHandler .html .htm
    AddType application/x-httpd.php .html .htm
     
    krt, Sep 14, 2007 IP