PDA

View Full Version : Handling URL mis-spellings


awslawson
02-24-2009, 01:46 PM
I have a page at

http://www.yankgulchmusic.com/products.html

which works fine. Now I'd like to send users to that same page if they type

http://www.yankgulchmusic.com/Products

Using TelNet I've created soft links to send users from one directory to another, but always with names that include the .html extension. For example, while in my home directory I did:

ln -s ./DETAILSFILES/UnsungSongsDetails.html ./UnsungSongsDetails.html

This permits users who type

http://www.yankgulchmusic.com/UnsungSongsDetails.html

to be directed to the page at

http://www.yankgulchmusic.com/DETAILSFILES/UnsungSongsDetails.html

This doesn't work without the .html extension. Following a suggestion from the FutureQuest desk I created a directory out of the URL name without the extension and went on from there to get at least a partially OK result.

Is there some other way to accomplish what I want to do without using soft links?

johnfl68
02-24-2009, 02:10 PM
I think you can do this with a redirect in your .htaccess file. I have never tried to go from a folder to a file, but the second one should work fine.

Redirect is the redirect
301 states that the file is moved permanently
/old.htm is the file that people entered (do not use the full address for this)
http://www.mysite.com/new.html is the page you want people to go to (must use full address)

Something like this perhaps:

Redirect 301 /Products http://www.yankgulchmusic.com/products.html
Redirect 301 /UnsungSongsDetails.html http://www.yankgulchmusic.com/DETAILSFILES/UnsungSongsDetails.html


If you google search "htaccess redirect" there are many sites on this. There are several ways to do things, depending on what you are trying to do.

Be careful using htaccess, as you can case problems very easily.

John

Kevin
02-24-2009, 02:32 PM
The biggest problem you will encounter with symlinking a file.html to directory/index.html is that any relative URLs within the html file to things like images will be wrong. IOW, if within that html file there is a reference to images/image.jpg that would be ../images/image.jpg from within the sub directory.

You can fix that by either using all absolute URLs within the HTML file or by making even more symbolic links. Or you can use a rewrite instead of symbolic links.

awslawson
02-25-2009, 11:14 AM
Hi Kevin,

What do you think about the suggestion by johnfl68 to use .htaccess to Redirect the offending URL address?

awslawson

Kevin
02-25-2009, 11:23 AM
A Redirect is a perfectly valid way to handle the problem. So is a ReWrite though they are easier to screw up.