Forum Home
Press F1
 
Thread ID: 73611 2006-10-26 07:20:00 How to do short urls stu161204 (123) Press F1
Post ID Timestamp Content User
494468 2006-10-26 07:20:00 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?
stu161204 (123)
494469 2006-10-26 07:43:00 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). TGoddard (7263)
494470 2006-10-26 08:22:00 Umm by default index.html is loaded. For other pages you would do this in .htaccess


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 :)
trinsic (6945)
494471 2006-10-26 08:29:00 Would that work if the file was .html? not .php stu161204 (123)
494472 2006-10-26 09:17:00 Yup.

.htaccess and mod_rewrite work with anything :)
trinsic (6945)
494473 2006-10-26 09:34:00 It appears I forgot how to use mod_rewrite :D

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

EDIT:


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.
trinsic (6945)
494474 2006-10-26 10:49:00 Thank you for your help trinsic :), Will let you know how I get on :D stu161204 (123)
494475 2006-10-26 15:12:00 Just create the directory, stick your index file in there, and presto, no need to use index.html. Greg (193)
494476 2006-10-27 03:03:00 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!!!. Rob99 (151)
494477 2006-10-27 04:12:00 All these are workarounds: a URL points to a file. if you request host.domain.tld 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). Graham L (2)
1