Results 1 to 10 of 10
  1. #1
    Senior Member
    Join Date
    Dec 2004
    Location
    Auckland
    Posts
    5,069

    Default How to do short urls

    Is it possible to turn this:

    computers-and-internet/programming-and-development/index.html

    In to this:

    computers-and-internet/programming-and-development/

    ???

    I think it can be done with mod -rewrite but I am not sure how to do it

    Any ideas?

  2. #2

    Default Re: How to do short urls

    What do you want to do? Visit the bottom URL and the server will load index.html automatically (the possible default files will be listed in the server configuration).
    Why use a simple solution when a complicated one will suffice?

  3. #3
    in for the kill
    Join Date
    Aug 2006
    Posts
    750

    Default Re: How to do short urls

    Umm by default index.html is loaded. For other pages you would do this in .htaccess

    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    RewriteRule ^file\.php$ / [QSA,L]
    With file being the name of the file you want loaded in that directory.

    Eg.

    mydomain.com/duck/goose.php

    If file was changed to goose then when you went to mydomain.com/duck it would load up goose.php (but wouldn't actually show you it was).

    Hope that helps

  4. #4
    Senior Member
    Join Date
    Dec 2004
    Location
    Auckland
    Posts
    5,069

    Default Re: How to do short urls

    Would that work if the file was .html? not .php

  5. #5
    in for the kill
    Join Date
    Aug 2006
    Posts
    750

    Default Re: How to do short urls

    Yup.

    .htaccess and mod_rewrite work with anything

  6. #6
    in for the kill
    Join Date
    Aug 2006
    Posts
    750

    Default Re: How to do short urls

    It appears I forgot how to use mod_rewrite

    If you are using just index pages in your folders then you do not need to put /index.html but simply /

    EDIT:

    Code:
    DirectoryIndex index.html
    It couldn't get any easier hah!

    Change index.html with your choice.

    Place the .htaccess in the folder you want it to work in.
    Last edited by trinsic; 26-10-2006 at 09:43 PM. Reason: Found out how ;)

  7. #7
    Senior Member
    Join Date
    Dec 2004
    Location
    Auckland
    Posts
    5,069

    Default Re: How to do short urls

    Thank you for your help trinsic , Will let you know how I get on

  8. #8
    Modulator Greg's Avatar
    Join Date
    Dec 2004
    Location
    Napier
    Posts
    9,115

    Default Re: How to do short urls

    Just create the directory, stick your index file in there, and presto, no need to use index.html.
    Bugger the cancer. I'm suffering from terminal inertia.

  9. #9
    Jedi master Rob99's Avatar
    Join Date
    Dec 2004
    Location
    In the wop wops
    Posts
    3,532

    Default Re: How to do short urls

    index.htm/l, index.php, index.asp/x ... you dont need these if you are pointing to the folder as they will load by default!!!.
    Laziness is nothing more than the habit of resting before you get tired.

  10. #10
    Pedant and proud of it
    Join Date
    Dec 2004
    Location
    Christchurch
    Posts
    6,047

    Default Re: How to do short urls

    All these are workarounds: a URL points to a file. if you request http://host.domain.tld/name1/name2 the server will look in the directory "name1" for a file called "name2". If "name2" is actually a directory too, (and there is no file with the same name ) the server should reply with a 404 error. There is in fact no such file. (Browsers used to see the error, and try appending a slash character to the user's request and trying again, rather than displaying the 404 error. That user error is so common that it's probably handled in web servers now). If you request [b]...[name1/name2/[b] (with the slash), the server is usually set up to provide a default file. (I think a server can also be set up to generate a file to return if one doesn't exist. This could be useful for a FTP upload directory, which could provide a current directory listing, automatically generated on request).

Similar Threads

  1. cannot conect to some urls
    By colcooke in forum PressF1
    Replies: 8
    Last Post: 20-04-2007, 06:13 AM
  2. URLs
    By bba12 in forum PressF1
    Replies: 7
    Last Post: 28-10-2004, 10:47 PM
  3. Thunderbird and URLs
    By Raymondo in forum PressF1
    Replies: 2
    Last Post: 03-10-2004, 08:09 PM
  4. Typed urls
    By ojos in forum PressF1
    Replies: 5
    Last Post: 01-06-2004, 07:31 PM
  5. OT: CF1, PF1 URLs - which do you use?
    By agent in forum PressF1
    Replies: 3
    Last Post: 13-02-2003, 05:46 PM

Posting Permissions

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