Hi All,

Someone just told me that if you name your pages .php, it hinders your rankings.

Is that true?

Thanks


Michelle

Dani AI

Generated

Short answer for : the file extension alone (.php vs .html) is not what determines rankings. What matters is whether your URLs are stable, unique and crawlable. Several replies here correctly point at the real problems (session IDs, parameter permutations, duplicate URLs) — the practical fixes below fill in the gaps.

If your site is appending session IDs or many parameter combinations into links, search engines see lots of near-duplicate URLs. Prevent PHP from propagating SIDs in links by preferring cookies and disabling transparent SID support early in your bootstrap:

ini_set('session.use_only_cookies', '1');
ini_set('session.use_trans_sid', '0');
session_start();

Apply that before any output. Also avoid including session tokens in query strings when building internal links.

Use canonicalization and redirects to consolidate URL variants. Add a canonical link tag on pages you control, and issue 301 redirects when you permanently change a URL:

<link rel="canonical" href="https://www.example.com/clean/path/" />

If you want user-friendly paths, server-side routing/rewrite is useful, but treat it as a usability/maintenance improvement rather than an SEO magic trick — always test links and redirects. An example rewrite mapping (Apache) looks like:

RewriteEngine On
RewriteRule ^product/([0-9]+)-([a-z0-9-]+)/?$ /product.php?id=$1 [L,QSA]

Quick checklist (practical): audit your site with a crawler to find URLs with “?” or SIDs; fix PHP session settings; implement rel=canonical or 301s for duplicates; expose an XML sitemap; mark ephemeral or user-only pages (like some “tell-a-friend” flows) noindex or avoid linking to them. Tying back to this thread: and are right to flag session/parameter issues, ’s idea of cleaner URLs helps UX, and / show why you should verify what actually gets indexed after changes.

Recommended Answers

All 7 Replies

Yes but you can use mod_rewrite to trick the search engines. You can find a guide here. It sorta makes my head spin tho :mrgreen: I have problems with regular expressions. Certain pages on this site use mod_rewrite, even tho they are .php and generated dynamically they will show up as .html in the address bar of your browser.

If only your .php contains session ids then only you have a problem otherwise they get indexed just fine!

First of all thats not true, it depends on how you use php.

As pulse added the problem is related to the fact that PHP uses in some cases session ids in the url and since session changes from user to user the URL looks different at the "eyes" of a search engine. PHP pages are dynamic so you will find in most cases question marks in the url... for example http://www.mydomain.com/showuserinfo.php?userid=222

Google doesnt seem to pay lots of attention to this since it means dynamic conent, maybe automatic information and marks that as not so relevant information. Poeple use dynamic page sto fool search engines and Google pays attention to that also.

I don't know how much relevan or not relevant a dynamic page url (with query string) is for Google.

however if your site has good content and good links pointing to you you, good navigation you should not have problems with clean url .php pages

a php extension by itself will not hurt you... but yes, try to use clean urls. Use search engine friendly urls and try to avoid query strings as much as you can.

Dani says: PHP sites are better. They are as indexable by the engines, as long as there are no query strings. PHP sites are more interactive and provide far more flexibility than HTML. They present a more professional image, by showing that your are up to date with the current technology. HTML is rather old school.

Avi Wilensky

HTML is rather old school.

I would respectfully disagree! :) What if the company doesn't need it for the most of its site? Like I am working on a corporate site for a client and except for a section to manage Press Releases, the whole site would be static! :p

Well, Why would I unnecessarily put .php on the static pages? For most of the non-tech people, as most of our visitors there would be, extensions don't make any sense! They don't know what .php is and leave aside a more professional image, by showing that we are up to date with the current technology.

Also, you can't tell by looking on the urls of the pages, if that page has been statically generated or by a site. For example this page that you are seeing right now has a .html extension, but it was generated by vBulletin... that's php hidden by mod_rewrite!

Our website is designed using PHP and the site seems to be indexed
However, we have a dynamically generated link called Tell-a freind, which is from the page the visitor is in and does not get indexed becasue it has charecters such as ? in the URl and is not stored on the server

URLs with query strings get indexed just fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.