Jump to content

Recommended Posts

I am switching my site from html to php.

 

When building it I made sure not to have any extensions on links(e.g. http://philipk.ca/portfolio instead of ..portfolio.html)

 

I thought by doing this I could just delete portfolio.html and upload portfolio.php

and visitors would automatically be directed to the php page.

 

I just deleted the html file and uploaded the php and its not working.

 

Is there a setting that can be changed to tell the server to look for php instead of html?

Link to comment
https://forums.phpfreaks.com/topic/229592-going-from-html-to-php/
Share on other sites

The extension is actually part of the filename.  It's especially difficult because the native operation of an extension-less name denotes a directory.  Depending on what type of server you're using you may be able to deploy some rewrite rules that actually re-write the URL to point to the php script but this also depends on your directory structure. 

 

You're in a bit of a fix here.  I'd really suggest grepping through your code and changing links without extensions to links with extensions. 

 

Anyone else know a better way??

Hey,

 

I appreciate the reply but could you explain why you would include them?

 

Not having them has the advantage of looking more professional and being easier to manage if I'm changing .html to .php I have to go back and change all the links.

 

Also I am using Godaddy Grid hosting if that gives any insight into how much control I have.

.htaccess is what controlls web directories on apache sevrvers, but not all hosting companies let you play with them (something of a headache from their point of view)

I still stick with the renaming links, and with a clever text editor using a find&replace you should speed things along. (of cource if you had included .html in all your links, even notepad could have handled the find&replace)...come to think of it - with the right folder permissions, you could write a php function to rename all the links in all the files....would take longer than doing manualy though  ;)

You need the file extension.  You can then use mod-rewrite (.htaccess) to control the files that the server points an address to.  Most all files I create are .php, I then create all of my links as .htm.  I use mod-rewrite to take any address that ends in .htm and find the correct .php file for it.  You could do the same for you situation, but right now, your server doesn't parse the PHP file, because it is set to only parse files that end in .php or .php5

 

Hope that helps.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.