Submit Your Article Forum Rules

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Renaming files from .htm to .php

  1. #1

    Renaming files from .htm to .php

    I want to convert one of my sites into a dynamic site with PHP because there is a lot of repetitive code on each page that I would like to put in a single php script to make the maintenance of the site easier.

    The problem is, the site is almost a year old and a lot of SEO work has been done on this site. Its traffic can still be greatly increased, but I do not want to loose the traffic I already get from the search engines.

    I have not access to the .htaccess file so I am forced to rename all my pages to php to have the code parsed by the server. Because of this I also can't do 301 redirects from a file with an htm/html extension.

    So the best way to do this is with a 0-second meta refresh, something that is supported by most browsers and accepted by most Search Engines as something similar to a 301 redirect. I know you need to stay away from JavaScript redirects, another reason why I switched to PHP to have more server side scripting done opposed to faulty client-side scripting.

    I have prepared all the html files with the proper meta refreshes, but I would like to know how long should I keep these "place holders" for my old pages on my server. The search engines may re-index my site and hopefully transfer the PageRank to the new pages, but what about all the inbound links from other sites (even some I may not be aware off) is it wise to keep these redirecting pages for an infinite time on my server.

    Thanks I appreciate the help.

  2. #2
    Senior Member adbart's Avatar
    Join Date
    Apr 2005
    Posts
    459
    Quote Originally Posted by random website
    Meta Refresh URL Redirect is an example of a meta refresh URL redirect. The code is quite simple.
    <meta http-equiv="refresh" content="8;url=http://www.seocompany.ca/index.html" />
    Meta tag refresh is known to not be very search engine friendly and is consider spammy because of its misuse. If you keep it up around 8 seconds it is said it is ok. This method displays the new page that the refresh points to.
    The thing about leaving the redirect high (8 secs or so) sounds like common sense.

    I'd consider putting it at 10 or something. Also, on each original .htm page, put a link to the new page on it, e.g:

    Code:
    <center>This page has moved.
    
    Click here to go to the new page.</center>
    Freelance IT consultant & SEO marketing
    Private message for contact information

  3. #3
    WebProWorld MVP Webnauts's Avatar
    Join Date
    Aug 2003
    Location
    European Community
    Posts
    9,028
    Never use meta refresh! Too risky!

    Do that with PH. See here how simple that is: http://php.about.com/od/learnphp/ht/phpredirection.htm

  4. #4
    adbart I used exactly the method you described but only with 0-second refresh. I will make it 10 seconds like you suggested. Luckily I have not uploaded any files yet so no damage done. Good thing I asked for advice first.

    Webnauts thanks for the page on PHP redirection. Unfortunately my web hosts only allow PHP parsing in .php files so no parsing is done in .htm files and like I said I have no access to the .htaccess file so I cannot configure the PHP settings on the server.

    But the link you provided was a lifesaver with a page of another site I had redirection problems with. The redirection worked on my local Apache server but failed once I uploaded it too my server. I never knew that the PHP code should be the only code in the file with no text to be sent to the browser before the PHP script. The redirection started working once I removed the other text from the file.

    I hit two flies with one question. Thanks guys!

    I just wonder why the redirection succeeded on my local server, which setting allows a mixture of HTML and the 301 PHP code in the same file? Any ideas?

  5. #5
    Senior Member
    Join Date
    Sep 2005
    Posts
    254
    You can set headers and have html in the same php file, but all calls to header() MUST be made before ANY html is outputted, or you will receive an error to that effect. If you didn't get an error on your local server you must have error reporting off (or very low)

  6. #6

    A meta refresh DANGER DANGER

    A meta refresh is an ultra dangerous method to use. Even though it sounds like you 100% ethical in you purpose, the spammers used that tag to excess and it just to much of a risk.

    Google says this about redirects.

    Don't employ cloaking or sneaky redirects.

    .htaccess with a 301 code is the best. If your server doesn't allow this, then switch servers. You shouldn't have to spend more $29 a month for quality hosting with root level and .htaccess.
    Serr.biz - Ethical SEO,SEM and Blog marketing
    Comprehensive e-brand marketing.
    Call 800.556.7449 for a free consultation.

  7. #7
    Senior Member DrTandem1's Avatar
    Join Date
    Oct 2003
    Posts
    1,828
    Some hosts allow a simple line of code in the .htaccess file that will treat each .html page as if it were PHP. You can then keep the page files as whatever.htm and still have the PHP function. Something like this:

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

    Are you sure you don't have access to the .htaccess file? If not, maybe change hosts to one that will work.
    DrTandem's San Diego Web Page Design, drtandem.com

  8. #8
    Senior Member
    Join Date
    May 2004
    Posts
    199
    If there is a lot of repetitive code, and the site is optimized..

    How about server side includes?

  9. #9
    Junior Member
    Join Date
    Nov 2006
    Posts
    20
    I totally agree with DrTandem

    If you really don't have the ability to modify your .htaccess, it is time to find a new host.

    There shouldn't be a need to change your file names and lots of scripts require htaccess to provide user friendly URLs.

  10. #10

    Get a new host!

    I'm with Andy on this one-- if you're sure you don't have access to the .htaccess file (or can't create one for each directory), then... forget about these guys, they're not worth hosting with anyway. Can you say who they are? It really sounds like they're giving you a raw deal.

    I'm using cheap hosting at 1and1.com and finding it perfectly serviceable for running wordpress blogs (though a bit sluggish at time, in the $10 a month plan I'm using). A really good host for Linux/Apache stuff, by all accounts (though I haven't tried them) is Media Temple (mediatemple.net). Have a look at both of these. I'm sure plenty of people here can recommend others as well.
    -a

Page 1 of 2 12 LastLast

Similar Threads

  1. URL Renaming in Google Search Results
    By mit in forum Google Discussion Forum
    Replies: 1
    Last Post: 11-18-2009, 03:20 AM
  2. Renaming of Web Pages (Google SEO)
    By Rick_001 in forum Google Discussion Forum
    Replies: 21
    Last Post: 02-08-2008, 12:01 AM
  3. Renaming Pages...
    By jordanmcclements in forum Google Discussion Forum
    Replies: 34
    Last Post: 09-01-2006, 07:05 AM
  4. Renaming Forums
    By wrmineo in forum WebProWorld: Guidelines/Announcements/Suggestions
    Replies: 2
    Last Post: 08-25-2005, 06:03 PM
  5. File renaming and effect on Google PR
    By giftsun in forum Search Engine Optimization Forum
    Replies: 3
    Last Post: 04-24-2004, 05:06 PM

Posting Permissions

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