Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Rewrite .php extension to virtual folder


jdMorgan - 12:22 pm on Feb 22, 2010 (gmt 0)


To clarify, one reason you're having problems is that

So, what I need is a set of rewrite conditions/ rules to rewrite my .php file extensions to a virtual folder ...

is exactly backwards.

You actually want to internally rewrite extensionless URLs used as links on your pages to .php files located inside your server.

To emphasize this even a bit more, understand that a URL 'exists' as soon as you (or someone else) defines it by linking to it. It makes no difference whether that URL resolves to a file on a server somewhere; the URL exists as soon as it is 'mentioned' in a link anywhere on the Web.

In contrast, a file exists on your server as soon as you create it or upload it there, regardless of whether there is a URL in a link that will resolve to it.

URLs and files actually have nothing whatsoever to do with each other, except that a server's primary function is to map its assigned domain's URL-space into its internal filespace.

With that in mind, the first response in this thread may become clearer: You need to take three steps. In conceptual order, they are:

First edit your HTML pages and/or the scripts that produce the HTML of your pages, and remove the .php extensions from your links.

Next, you want to internally rewrite these new extensionless URLs, when requested by HTTP clients from your server, to the currently-existing files (still) having .php extensions inside your server.

In practical order, you'll really want to have the rules in place before changing your links, but it seems to be helpful to describe these two steps in reverse. That's because it seems that it's easier for readers to understand when when we say, "Change your links, then make your server recognize the new links and point them to the old files."

Once these first two steps are is working, you'll then want to get rid of .php extensions on URLs saved as clients bookmarks, linked-to by third-party Web sites beyond your control, and currently indexed and listed in search engine results. So now, the recommendation supplied by g1smd above comes in: You'll want to externally redirect only direct client requests for the old URLs ending in .php to the new URLs having no extension.

Note that an internal rewrite is a URL-to-filepath translation, while an external redirect is a URL-to-URL translation. An external redirect doesn't even access a file; it is a server response telling the client, "That resource has moved, ask for it again using this new URL."

This thread [webmasterworld.com] may be of some assistance. Please note that the thread title was chosen by the original poster.

Jim


Thread source:: http://www.webmasterworld.com/apache/4084680.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com