Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite to remove .php

halfway there

         

wesg

9:56 pm on Apr 17, 2008 (gmt 0)

10+ Year Member



I have managed to redirect my URLs so /xyz/ is actually reading /xyz.php but now I have little problem.

This only redirects those requests coming in to /xyz/, which means the .php requests are still there. These aren't good SEO practices, and Google will likely find the duplicate material.

How can I redirect /xyz.php to /xyz/ before applying my original rule? The final goal is to remove the .php extension from the page filenames.

Thanks!

jdMorgan

10:48 pm on Apr 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's the classic procedure in logical order. In practice, swap steps 1 and 2.

  • Change all links on all your pages to remove the ".php". Do not add a slash.
  • Internally rewrite all extensionless requested URLs (those not having a "." in the final path-part or a slash at the end) to the same URLs plus ".php".
  • Externally redirect all direct client requests (and only direct client requests, not internally-rewritten requests) for .php URLs to extensionless URLs.

    There are many threads here on extensionless URLs. Try searching this site for that phrase, plus "RewriteRule".

    Jim

  • wesg

    11:46 pm on Apr 17, 2008 (gmt 0)

    10+ Year Member



    Thanks morgan,

    I was able to get the desired result by using these previous threads.

    [webmasterworld.com...]
    [webmasterworld.com...]