Jump to content

Search engines: Going from .html-files to .php-files on my web site


svesiver
 Share

Recommended Posts

I have used html-files for my website for more than a year. Now I have changed to php-files because I use #include files for my header, navigation and footer.Question: Will the search engines have any problem locating my pages? Same question for the users of the site.If the answer is yes, do you now any smart tricks to solve / avoid the problem?

Link to comment
Share on other sites

Search engines will have to reindex your pages, which in turn means recollecting your page rank. This wouldn't be a problem if people don't link to specific pages of yours (but just link to your home page). Similar with users.Instead of changing HTML files into PHP files, change file names to folder indexes. That way, if in the future for whatever reason you change from PHP to something else, you won't have to go over the same line of trickery again. That is, instead of

/about.html

have it as

/about/

and have index.php in the about folder.As for how to minimize the SEO and user impact... create an .htaccess file at the root of your site, and use something like:

RedirectMatch 301 (.*)\.html $1/

Link to comment
Share on other sites

Search engines will have to reindex your pages, which in turn means recollecting your page rank. This wouldn't be a problem if people don't link to specific pages of yours (but just link to your home page). Similar with users. Instead of changing HTML files into PHP files, change file names to folder indexes. That way, if in the future for whatever reason you change from PHP to something else, you won't have to go over the same line of trickery again. That is, instead of
/about.html

have it as

/about/

and have index.php in the about folder. As for how to minimize the SEO and user impact... create an .htaccess file at the root of your site, and use something like:

RedirectMatch 301 (.*)\.html $1/

This seemed to work, but now I don't know how to use the original html-files for my sub-directories. I need to be able to avoid changing to php-files for my sub-directories. I assumed it was possible to do that by specifying the "AllowOverride None" for the sub-directories in the httpd.conf file, but that did not seem to work on my server (Apache/ 2.0.59 (Win 32) PHP/5.2.5). Tanks for any help!
Link to comment
Share on other sites

You can do the same file-to-folder procedure to HTML files too. You don't have to rename them to ".php".Simply create a folder for each HTML file named after the file, place the file in that folder and rename it to "index.html".If later you decide you to need PHP on those pages, you can just rename the file to ".php" and get PHP. You won't have to alter the URLs again.

Link to comment
Share on other sites

Just a quick Q on this. If Google, Bing, and all the others are expecting to see:site.com/about-us.html ..and instead they land on:site.com/about/ (which works out to: site.com/about/index.html) ..would that not be just as problematic as just switching to .php file names in terms of confusing the search engines? I love the look of the URL in a directory format but I can't picture someone converting the whole site to dirs with a single index.html inside.. that would be crazy looking? I know we had a problem like this with .inc files having PHP code in them and this is what we put in the .htaccess to make it work:

RemoveHandler .html .htm .incAddType application/x-httpd-php .php .htm .html .inc

Seems like a super easy way to go, then all the files stay the same and PHP works when it's inside HTML?

Link to comment
Share on other sites

Just a quick Q on this. If Google, Bing, and all the others are expecting to see:site.com/about-us.html ..and instead they land on:site.com/about/ (which works out to: site.com/about/index.html) ..would that not be just as problematic as just switching to .php file names in terms of confusing the search engines? I love the look of the URL in a directory format but I can't picture someone converting the whole site to dirs with a single index.html inside.. that would be crazy looking? I know we had a problem like this with .inc files having PHP code in them and this is what we put in the .htaccess to make it work:
RemoveHandler .html .htm .incAddType application/x-httpd-php .php .htm .html .inc

Seems like a super easy way to go, then all the files stay the same and PHP works when it's inside HTML?

Yes, I think I am on the right track now (now I use php-files inside html-files). First I think I used this code (on my own Apache server): AddType application/x-httpd-php .html , but it did not seem to work. Then I used this: AddHandler cgi-script .cgiAddType application/x-httpd-php .html and it worked! Then I removed the AddHandler line and it still worked. However, it is problematic using IE, I run IE8. It seems that IE does not interpret the CSS-commands the same way as the other browsers do. The fonts look different and the positions of elements are slightly different from the other browsers I tested (Chrome, Safari, Opera, Firefox). How to cope with this?
Link to comment
Share on other sites

Did those problems exist earlier (before the html-to-php move)? If so, create a new topic about them in the CSS forum.The fonts in general look different across browsers, as they perform different non standardized font smoothing. W3C allows for this, as long as the boxes (i.e. the elements) remain the same sizes, which IE8 follows most of the time.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...