Results 1 to 2 of 2

Thread: index w/o extension confusing query string with directory

  1. #1
    Join Date
    Mar 2007
    New York, NY
    Thanked 66 Times in 66 Posts

    Default index w/o extension confusing query string with directory


    No code is necessary to explain this dilemma. What I've done is I've set my .htaccess file to allow PHP script files to have the option of NOT having the .php extension.

    Now, I want the index file to determine query strings, like so:

    That works just fine for me. However, if I try this:

    ... it is recognized as a directory on the server. Is there any way I can get around this? It seems that sites such as youtube and facebook are able to do this.


    Thanks in advance for all responses.
    Last edited by JShor; 09-02-2009 at 04:13 PM.
    - Josh

  2. #2
    Join Date
    Apr 2008
    Limoges, France
    Thanked 61 Times in 61 Posts


    I don't have any experience with removing file extensions, so I can't speak to that, but I can tell you that this is not what facebook and youtube are doing.

    Facebook and youtube and many other sites use mod-rewrite or an equivalent to send all requests to one file, usually the "index" file in the site's document root.

    From there the url is parsed and the relevant page is returned.

    So, is actually being sent to "index.php" where it is determined that the request is for the "username" page.

    As for your query string example, if you change nothing at all in .htaccess (or don't even have a .htaccess file) and go to, you will see your site's "index.php". MyQueryString does not get put into the $_GET array. However, if you replace "index" with anything else, a directory is looked for and you'll get the 404.

    So what you are explaining is "default" behavior. I don't think anything you have changed in .htaccess is causing it.

    If you are able to access 'MyQueryString' in your url, I'd be interested to know how you are doing it. Unless you are parsing the whole URL, I don't think that 'MyQueryString' will exist in the $_GET array. Let me know.

  3. The Following User Says Thank You to JasonDFR For This Useful Post:

    JShor (09-02-2009)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts