Results 1 to 5 of 5

Thread: mod_rewrite url's???

  1. #1
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default mod_rewrite url's???

    Hi,

    I see allot of sites (even dynamicdrive) that dont have file extenstions in there url's, they only have a slash.

    e.g. instead of www.somedomain.com/example.html they have www.somedomain.com/example/

    How is this done??

    ive looked into mod_rewrite's and redirects for .htaccess, etc, but nothing seems to be right.

    Any help on the matter would be great!

    Thanks
    Last edited by linkrus; 11-17-2006 at 11:56 PM.

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by linkrus View Post
    I see allot of sites (even dynamicdrive) that dont have file extenstions in there url's, they only have a slash.
    There's a difference between having no "extension" and a path that ends with a slash. The latter is a canonical URL referring to a directory on the server[1]. That is,

      http://www.example.com/foo/

    refers to a directory, foo, at www.example.com. What happens next is a bit of magic on the part of the server: there will usually be a directive in the configuration that tells the server to look for a certain file if a request identifies a directory, rather than some other resource. If that file can be found, it's served to the client.

    On Apache servers, this directive is named DirectoryIndex, and the default value is index.html. So, given the URL above, the server would look for a file named index.html in the foo directory. It's essentially the same thing as requesting

      http://www.example.com/foo/index.html

    directly, though if index.html doesn't exist, the server will respond in different ways to those two URLs.

    Actually handling "extension-less" URLs is more complicated, and I've briefly described four methods in two previous posts. The information in the second linked post starts about halfway though, after the quote:

    Also, Mike, I would like to know more if its not too much trouble,
    Mike


    [1] That's not necessarily true, but it's the most common situation, and it'll do for this explanation.

  3. #3
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mwinter View Post
    On Apache servers, this directive is named DirectoryIndex, and the default value is index.html. So, given the URL above, the server would look for a file named index.html in the foo directory. It's essentially the same thing as requesting
    Thanks for helping me out.

    I already knew that index is the default for a directory but i thought there was more to it than creating a directory folder for every page??

    The reason im interested is this is because i read that you can also use this kind of linking method to improve seo for dynamic url's
    e.g. http://www.somedomain.com/index.php?page=example chould be linked to like http://www.somedomain.com/example/

    This is suppose to help with search engines indexing links and ofcourse its easier to type in directly.

    Again thanks for your help.

  4. #4
    Join Date
    Nov 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    if you know regular expressions, the documentation for it should help you.

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by linkrus View Post
    I already knew that index is the default for a directory but i thought there was more to it than creating a directory folder for every page??
    As I wrote in the cited thread, doing that is impractical, certainly for any reasonably large site. Even on a smaller one, it's far from ideal.

    The reason im interested is this is because i read that you can also use this kind of linking method to improve seo for dynamic url's
    e.g. http://www.somedomain.com/index.php?page=example chould be linked to like http://www.somedomain.com/example/
    Well ideally one wouldn't create URLs like the former in the first place.

    This is suppose to help with search engines indexing links
    Search engines aren't fond of documents the use query string parameters, though they will index them (Google indexes DD, for example). I don't know where the line is, though - SEO doesn't interest me that much.

    and ofcourse its easier to type in directly.
    Quite, which is why URIs should be designed to be simple from the outset.

    You could use mod_rewrite to perform an internal redirect, but it would be necessary to modify the server configuration at the main server or virtual host level. As far as I can see, distributed configuration files (.htaccess) are too limited in ability to be useful, here. That is to say that I can get it to work on my test server, but only by modifying http.conf.

    Mike

Bookmarks

Posting Permissions

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