SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to switch my index.html to index.php

    By now, I've submitted my site to most major directories in http://www.mydomain.dom/index.html?ref=ref_no form to keep track of my traffic. It's a 3 year old site and there are hundreds of links to it in the form indicated above.

    I wouldn't like to have visitors crashing a "your URL is not on this server any more" message.

    Can anyone think of a way to handle this?

    thank you

  2. #2
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use a simple meta-redirect tag, but that way you can't pass on the variables.

    You'll have to use something else to acomplish this: like configuring the server so that PHP tags will be parsed in scripts with a .html extension.

    Maybe you can use Javascript for this, but I'm not sure about that.
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  3. #3
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suppose you could do something like..

    <SCRIPT LANGUAGE="JavaScript"><!--
    queryVar = this.location.href;
    var inq = queryVar.indexOf('?');
    queryVar = queryVar.substring(inq + 1);
    location.href = "index.php?" + queryVar;
    //--></SCRIPT>

    Although the above code will work absolutely fine, I think a better solution may lie with a .htaccess file to provide a more "seamless" swap over.

  4. #4
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As Elledan says javascript is a possibe, the window.location object holds the address of the current page, so for this page the window.location would be

    http://www.sitepointforums.com/newre...threadid=14113

    so

    <SCRIPT>
    query =window.location;
    str="";str +=query;
    newstr=str.replace(/html/i, "php");
    location.href=newstr;
    </SCRIPT>

    should do the job, only tough for those withpout javascript, in which case leave a link or something.


    OOOPS didnt see ya there Peter! DOh , interesting though ,2 versions of the same answer!

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Javascript solution is quite satisfactory but a server side solution would be great.

  6. #6
    SitePoint Enthusiast ericd's Avatar
    Join Date
    Nov 2000
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could create a ".htaccess" file in the directory with

    <Files index.html>
    ForceType application/x-httpd-php3
    </Files>

    and this way you can still php parse the file, so you wont need to change the file to .php


    Hope this helps.






  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think a better way tio write that would be

    AddType application/x-httpd-php .html

    instead of

    <Files index.html>
    ForceType application/x-httpd-php3
    </Files>

    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What if I make a globbal change in the server's configuration file to have all html files parsed as php files? Would it cause any problems or create any overload to system resources?

  9. #9
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by keko
    What if I make a globbal change in the server's configuration file to have all html files parsed as php files? Would it cause any problems or create any overload to system resources?
    This would be totally unnecessary and only use more resources than necessary, since it would require the server to scan all .html files, while just one (the index.html file) has to be scanned and parsed.

    I'd go with the .htaccess solution.
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  10. #10
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Icreated a .htaccess file and typed

    AddType application/x-httpd-php .html

    in it. But still it doesn't parse .html files in that directory as php files.

    thank you

  11. #11
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of PHP? IF it is version 3 then you need to change it to:

    AddType application/x-httpd-php3 .html
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  12. #12
    SitePoint Enthusiast ericd's Avatar
    Join Date
    Nov 2000
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in the .htaccess try


    <Files index.html>
    ForceType application/x-httpd-php3
    </Files>




Bookmarks

Posting Permissions

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