Jump to content

Extensionless files


MinuteMan
 Share

Recommended Posts

Nowadays, I see many sites using the following navigation: http://example.com/articles/PHP/1/I know that these are not directories but extensionless files, and I need to know how they are made.My root folder is htdocs/. I have an index (no extension) file, which contains PHP codes.I've typed in my .htaccess the following:

DefaultType application/x-httpd-phpForceType application/x-httpd-php

So far, so good. I can open /index w/o problems.But when I try to open /index/ it parses it like a directory..I hope you can tell me where is my mistake, so I can open /index/ as the index file.PS:It's 2:00 AM, I want to go to bed and I know my English is bad. I can explain more detailed tomorrow, if you don't understand.

Link to comment
Share on other sites

Thank you for the answer.I googled about mod_rewrite and read some very interesting tutorials and guides.I think I got it - in my .htaccess file I have:

RewriteEngine onRewriteRule ^index/?$ index.php [L]

This will open http://mydomain.com/index and http://mydomain.com/index/ as the index.php file.I use a stylesheet in index.php.When I go to http://mydomain.com/index/ it doesn't parse the stylesheet and my page is shown without any styles.Maybe I am very close to it, but just don't have an idea how to do it.

Link to comment
Share on other sites

mod_rewrite is messing up the stylesheet path. When people do something like this:http://example.com/articles/PHP/1/They are not using extensionless files. This is pointing to a directory on the server, and the server will look in that directory for an index file. The server is configured to say which index files to look for and in which order, for example it may look for index.html, index.php, default.html in that order. If an index file is not found, then the server will either show a directory listing of the files in that directory, or if that is disabled it will show a Forbidden error.But the point is that people aren't using extensionless files, they just use the index file for the directory. If index.php is not set up as an index file, then add it to the server's list of index files to look for. That will be the easiest way, and then mod_rewrite won't mess up paths to other files.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...