Forum Moderators: phranque

Message Too Old, No Replies

Urls without any extension

.php or .html should not be shown to the user

         

none

9:00 pm on Aug 18, 2010 (gmt 0)

10+ Year Member



Hi to all,
I have searched the forum and found many discussions related to my question but i am a bit confused.

I have a static website of 80 pages written in HTML. All the pages have .HTML extension. I am doing very well in search engines for my main keywords. Now I am trying to expand my site to a larger number of pages but with HTML it is very difficult to manage all the pages one by one. For example If I have to add a new link to the main menu of my website I have to edit 80 pages one by one.

So what I am thinking is using PHP to separate header, sidebar and footer like this in my files.
<?php include('includes/header.php'); ?>
<?php include('includes/sidebar.php'); ?>
<?php include('includes/footer.php'); ?>
But I have read some where that it slows down the loading speed and there are some security issues also. is it right?

Should I implement this technique on the existing 80 pages keeping my SE rankings and back links in mind?
or should I implement it only to the new pages that I would create?

If I implement this technique to my existing 80 pages all the .HTML extension will be changed to .PHP and it will affect my SE rankings and back links also. any solution?

And the URLS of my new pages that I create with PHP INCLUDE technique will look like this (excluding the index pages).
www.myweb.com/dir/page.php
www.myweb.com/dir/dir/page.php

Can i change them to something like.
www.myweb.com/dir/page
www.myweb.com/dir/dir/page
eliminating the .php extension using rewrite rules.

Is my approach right? should i keep them with .php extension or eliminate the extensions? whats the difference?

If anyone has a better idea please share. Regards.

g1smd

11:44 pm on Aug 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can use AddType or AddHandler and keep your .html files and your .html URLs, but still allow those files to contain PHP instructions.

Do not change to .php URLs. You could go "extensionless", and that would be better in the long term, but you might not need to do it yet.

The "includes" idea is great. It will save you a HUGE amount of work in the long run.

Since the included files are small, page loading speed will not be greatly affected. The many other potential benefits outweigh any changes there.

Make sure the link to your root page is in the form "www.example.com/" with NO index filename mentioned at all.

jdMorgan

12:54 am on Aug 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In correct terms, you will put links on your pages to extensionless URLs, and then use server-side configuration settings or code to resolve those extensionless URLs to the proper files (which do have extensions). URLs and files aren't the same thing, and this is usually the main point of confusion.

The security issues have to do with PHP itself. Make sure that the version of PHP installed on your server (now and at all times in the future) is fully up-to-date and be sure to use a very strong password on the PHP administration "control panel."

A search of WebmasterWorld for "extensionless URLs" will turn up several useful previous threads.

Jim

none

9:47 am on Aug 19, 2010 (gmt 0)

10+ Year Member



Thanks g1smd and jdMorgan.

@g1smd [You can use AddType or AddHandler and keep your .html files and your .html URLs, but still allow those files to contain PHP instructions.] Can u please explain how to do it?

@jdMorgan [use server-side configuration settings or code to resolve those extensionless URLs to the proper files.] Can I get the code.

Regards.

jdMorgan

2:50 pm on Aug 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This issue is likely more complicated than you think. There are a lot of details that we don't/can't know without spending a week or a month working on your site. Such details make answering your questions impossible (without spending a week or a month guessing at possibly-correct answers).

Also, please do the site search suggested above. There are several very good threads posted here on extensionless URLs. Those threads took many hours of contributors' time, and are worth reading. Since the information is already in those threads, contributors likely won't re-type it all here...

This is server configuration code, and not something that you can just copy-and-past with any reasonable expectations of success.

Please spend a few days with the Apache documentation at apache.org, and then post specific questions.

Apache mod_mime and mod_rewrite would be most-related to your current questions.

Jim