View Full Version : Redirecting subdirectory ABC to abc
jelevin
03-20-1999, 06:09 PM
Is there some easy way to redirect or otherwise link a subdirectory to another? If my users type WWW.MYDOMAIN.ORG/ABC I want to redirect to www.mydomain.org/abc
(I know this isn't really an advanced development question, but it seemed to fit best here)
Thanks.
Terra
03-20-1999, 10:07 PM
sure, here's the quick'n'dirty way...
1) Telnet into your account
2) change to where the ABC directory is located... e.g. if www/ABC, then change directory to www/
3) pull out our handy dandy 'ln' (Link) tool...
$ln -s ABC abc
4) Voila! Apache will now see it either way...
--
Terra
--The symbology of it all, never guarantee's uniqueness--
FutureQuest
Mandi
03-22-1999, 09:23 AM
Is this just a bandwith enhancing thing (ie, utilize users cache better) or is there an even better reason to do this?
Jacob Stetser
03-22-1999, 10:05 AM
Mandi,
I think he wants to do that because some users haven't figured out that computers can type lower-case letters now.
In other words, they don't know how to use the shift/caps-lock key so they always type in uppercase letters.
Linux is case sensitive so www.domain.com/ABC is different from www.domain.com/abc. He wants to make them act the same so that even the all-capsers still get what they want.
http://www.aota.net/ubb/smile.gif
jelevin
03-22-1999, 09:16 PM
That's correct, and the instructions worked perfectly. Thank you.
blobpet
06-08-1999, 07:11 AM
Is there a way for me to enable the linking of www/HELLO to www/hello automatically without me having to use the "ln" on every directory?[nbsp][nbsp]
Also, how do I view which directories/files have had the "ln" applied to it?
LeafWind
06-08-1999, 10:31 AM
Blobpet: I don't have any answers, but I wanted to thank you for moving this topic up to the top again just when I needed it.
Sometimes it's not the visitor's fault -- I just found out a net-illiterate client I have hosted in a subdirectory has been giving out "approximations" of the URL to those she wanted to visit the site, saying "it's close enough, the internet will know what to do."[nbsp][nbsp]Argh.[nbsp][nbsp]At least I can catch some of those approximations now, provided she got the domain name right. :(
Bekariso
------------------
www.LeafWind.com (http://www.LeafWind.com)
Growing web sites that thrive in the winds of change.
Another thing you might try is (mis-)using your 404.php3
When a directory isn't found, check if the lowercase-version exists and set a Location-header.
Pier
LeafWind
06-08-1999, 01:02 PM
Blobpet asked:
Also, how do I view which directories/files have had the "ln" applied to it?
Answer: In my case, I linked www.leafwind.com/freedomroad/ (http://www.leafwind.com/freedomroad/) and www.leafwind.com/freedom/ (http://www.leafwind.com/freedom/) to the real directory of www.leafwind.com/FreedomRoad/ (http://www.leafwind.com/FreedomRoad/) .[nbsp][nbsp]When I then FTP'ed in using WS FTP Pro, I saw two new "half-folders" in my www/ folder with the names freedom and freedomroad.[nbsp][nbsp](By "half-folders" I mean the icon beside the name is half a folder icon and half the little box of 0's and 1's that WS FTP uses to indicate a binary file.)[nbsp][nbsp]Clicking on either of those in my FTP folder opens up my /FreedomRoad/ directory.
I'm not familiar enough with telnet (yet) to do anything other than follow explicit directions, so I don't know if there's a way to check it via telnet rather than FTP.
As for your other question, Pier's suggestion sounds like the "automagic" way to do it.
Hope this helps.
Bekariso
------------------
www.LeafWind.com (http://www.LeafWind.com)
Growing web sites that thrive in the winds of change.
I'm not familiar enough with telnet (yet) to do anything other than follow explicit directions, so I don't know if there's a way to check it via telnet rather than FTP.
when doing a ls -l you'll see a lrwxrwxrwx as 'mode' and
something like tmp -> /tmp/pier as actual filename:
drwxr-xr-x[nbsp][nbsp]2 pier[nbsp][nbsp]users[nbsp][nbsp][nbsp][nbsp] 512 Apr 24 10:25 Stats
drwxr-xr-x[nbsp][nbsp]2 pier[nbsp][nbsp]users[nbsp][nbsp][nbsp][nbsp] 512 Jan 14[nbsp][nbsp]1997 TODO
lrwxrwxrwx[nbsp][nbsp]1 pier[nbsp][nbsp]users[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]13 Jul[nbsp][nbsp]2[nbsp][nbsp]1998 TV -> /home/pier/TV[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]
Works also for files :)
Pier
[ Who now sees that his TODO-folder is REALLY old and think
it's ime to do something about it :) ]
[This message has been edited by pier (edited 06-08-99)]
Justin
06-08-1999, 03:03 PM
I always use all lowercase directories and filenames - I don't understand the need to make things more difficult to remember... I've been using all lowercase variables lately too. Just less to have to remember.
The UBB's variables are IMHO too long and case sensitive - things like $AltColumnColor2 and stuff like that - I'd just use $color1 and $color2, etc...
But anyway, I was going to suggest the smart 404.php file idea too - if you use all lowercase filenames and directories, you could do this:
<?
$lowercase = strtolower($REQUEST_URI);
if ($REQUEST_URI != $lowercase) {
[nbsp][nbsp] if (file_exists("/xdomain/www/$lowercase") {
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]header("Location: $lowercase");
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]exit;
[nbsp][nbsp] } else {
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]print "I can't find $REQUEST_URI anywhere - I even
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]tried it as $lowercase, and that's not here either...
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]are you sure you typed it correctly?? If not, well,
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]retype it. I really can't help you on this one...
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]sorry.";
[nbsp][nbsp] }
} else {
[nbsp][nbsp] print "Sorry, it ain't here. Try again...";
}
?>
Or something to that effect...
------------------
Justin Nelson
FutureQuest Support<!-- NO_AUTO_LINK -->
[This message has been edited by Justin (edited 06-08-99)]
I always use all lowercase directories and filenames - I don't understand the need to make things more difficult to remember... I've been using all lowercase variables lately too. Just less to have to remember.
Personally I like to use a capital first for directories. Very nice for a ls, (dir's first), very easy for management.
Pier
- (except for my /bin)
blobpet
06-08-1999, 10:26 PM
I have two problems with the 404.php file.
1) When I run it it gives me an error "Parse error: parse error in /big/dom/xtopcities/www/404.php on line 7".
2) I don't know how to link it so it gets displayed when there's a 404 error.[nbsp][nbsp]Seems like I need to have 404.html or it won't work.
Help!
On kinda a similar topic, how do you redirect from www.domain.com (http://www.domain.com) to domain.com (without the www).
[nbsp]I noticed when I type in FQ's url, it always adds the w's and caps, it's a nice touch.
[nbsp]Thanks.
The reason FQ is like that is actually a bit more complex...
FutureQuest.net is actually on the TAZ server.
www.FutureQuest.net (http://www.FutureQuest.net) is on the SIX server.
I build on SIX not on TAZ so I have TAZ redirected to SIX where the site is actually updated at. The reason FutureQuest is on two different servers is due to legacy issues that Andrew hasn't had time to work on it .. it involves the fact that sub-domains are also attached to our domain yadda yadda yadda.. it's all quite confusing actually :þ I *wish* it wasn't like it is...
All in all it's probably better to not force the www into the domain name since it will work for you either way ...
Deb
Justin
06-09-1999, 02:41 AM
Ah, I left out a ) on line 7 - it should read:
if (file_exists("/xdomain/www/$lowercase")) {
To link it as your ErrorDocument for a file not found, you have to use an .htaccess file - see http://www.aota.net/Tutorials/htaccess.shtml for instructions on that...
I have a habbit of throwing up untested code in the forums. I do this to give an idea of how, not as a full solution. You'll have to forgive me - they are just ideas that pop into my head, most of them just thought up as I post them. Sometimes they work and sometimes they don't without a little bug testing etc.
My goal when I do that is to give a little insight on how to accomplish a task, instead of just saying "use php" - it's a basic idea that should be expanded on to get the results you desire... my appologies for the confusion - I will from now on make it clear that it's just a basic "try this, it might help" type of thing, not a full blown working script that has been tested etc. In other words, use at your own risk, your milage may vary, yadda yadda yadda :D
------------------
Justin Nelson
FutureQuest Support
blobpet
06-09-1999, 11:39 PM
How do I delete a link that I've created with "ln" ?[nbsp][nbsp]
blobpet
06-10-1999, 12:57 AM
When I use the following php script, it doesn't work:
<?
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]header("Location: http://www.yahoo.com");
?>
[nbsp]
Neither does this:
<?
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]header("Location: index.htm");
?>
All I get is a blank page.[nbsp][nbsp]What's going on???????
[nbsp]
Justin
06-10-1999, 02:08 AM
Make sure the <? is the FIRST think in the file. You cannot send a header (or cookie) once you've sent the Content-type header. Once you try to print any text, the content type header is automatically sent - even if it's only a space or blank line in the file before the <? part...
Just make sure that's the first thing in the file and it will work.
------------------
Justin Nelson
FutureQuest Support
jenili
06-22-1999, 01:12 AM
How do I delete a link that I've created with "ln" ?
You just delete it as you would if it were a real directory. If you're using a graphical FTP client, select it and choose "delete". If you're using a telnet or secure shell client, one of these two will work (substituting the actual directory name created with "ln -s" for "linked-dir-name", of course) :
rm linked-dir-name
rmdir linked-dir-name
I forget which one will work; try 'em both and you'll know. Doing this will delete the symbolic link, but not the directory you linked to -- which is just what you'll want.
------------------
jeni
vBulletin® v3.6.8, Copyright ©2000-2013, Jelsoft Enterprises Ltd.