Web Hosting Forum | Lunarpages
News: Server Migrations to San Diego: Deneb, Felix and Tsohea are moving to San Diego starting Tuesday, December 30, 2008 at 10pm Pacific. They will complete their moves Friday night, January 2, 2009

Isis, Seth and Ez-web-n-mail will move physically on Friday, January 2, 2009

Please see the forum posts at http://www.lunarforums.com/lunarpages_web_hosting_server_information-b54.0/

+ Submit Your Own Web Site for the January 2009 Site of the Month Contest!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
January 07, 2009, 08:45:04 PM


Login with username, password and session length


Pages: [1] 2   Go Down
  Print  
Author Topic: How To Make URL's not case sensitive  (Read 8802 times)
JamesG
Lager Ship
Berserker Poster
*****
Offline Offline

Posts: 12026


If In Doubt, Cluster!


WWW
« on: December 08, 2004, 09:18:05 AM »

this was made by Nibbler, one of the PHP experts that lurks the Lunarpages forums... if you think this is good, you could visit his site, and give him your appreciation: http://coppermine.sourceforge.net/

as you know Lunarpages server are case sensitive which means if you had a page located at http://yourdomain.com/FILES/index.html and somebody typed in the browser http://yourdomain.com/files/index.html they would get a 404 error rather than the page you want them to see.

but if you add this into a .htaccess file and put it in your root directory (or public_html)

Code:
ErrorDocument 404 /404.php


and in the same folder put a file names 404.php containg the following

Code:
<?php
$lower 
strtolower&#40;$_SERVER['REQUEST_URI'&#93;&#41;;
$new 'http&#58;//' $_SERVER['HTTP_HOST'&#93; . $lower;

if &#40;file_exists&#40;ltrim&#40;$lower, '/'&#41;&#41; && $_SERVER['PHP_SELF'&#93; != $lower&#41;&#123;
header&#40;"Location&#58; $new"&#41;;
exit;
&
#125; else &#123;
echo 'Page not found';
&
#125;
?>


when someone types the correct URL, but in the wrong case, they will go to the correct page....

Thanks Nibbler
Logged

checkup
Spacescooter Operator
*****
Offline Offline

Posts: 34


« Reply #1 on: December 08, 2004, 09:52:06 PM »

This is useful. Thumbs Up

Seems to work for main page, but did not work for this case:

Page on web site is: TrialBSCbscr.htm


I typed in: http://www.mysite.lunarpages.com/trialbscr.htm
but got the Page not found message.

How can I extend the code to handle this?

(and also how could I include a home page link on the Page not found message?)

I'm new to php Embarassed
Logged
JamesG
Lager Ship
Berserker Poster
*****
Offline Offline

Posts: 12026


If In Doubt, Cluster!


WWW
« Reply #2 on: December 09, 2004, 01:28:16 AM »

where it says "Page Not Found" change that to what you want the page not found page to say Thumbs Up

there is an option in CPanel to customize your error pages!
« Last Edit: June 17, 2006, 08:53:22 AM by JamesG » Logged

Nibbler
21st century digital boy
Master Jedi
*****
Offline Offline

Posts: 1178



WWW
« Reply #3 on: December 09, 2004, 04:20:20 AM »

There is no way to handle that unless you want to try all possible combinations of capitalisation, which would just be silleh.
Logged

Missing since 1983

JamesG
Lager Ship
Berserker Poster
*****
Offline Offline

Posts: 12026


If In Doubt, Cluster!


WWW
« Reply #4 on: December 09, 2004, 04:44:35 AM »

i cant see many people going to a website and typing:

www.DoMaIn.CoM/DiR/InDeX.PhP
Logged

Lupine1647
Berserker Poster
*****
Offline Offline

Posts: 10868


« Reply #5 on: December 09, 2004, 01:46:09 PM »

I get some hits from people who forget to turn off caps lock, and you get INDEX.PHP
Logged
JamesG
Lager Ship
Berserker Poster
*****
Offline Offline

Posts: 12026


If In Doubt, Cluster!


WWW
« Reply #6 on: December 09, 2004, 04:40:40 PM »

but that would work with this script...
Logged

Lupine1647
Berserker Poster
*****
Offline Offline

Posts: 10868


« Reply #7 on: December 09, 2004, 05:49:00 PM »

Quote from: Garvey
but that would work with this script...


yea, but I thought you were talking about why would people want to use this script. (Ok, I'm sick today so I cn't think  ZZzzzz )
Logged
JamesG
Lager Ship
Berserker Poster
*****
Offline Offline

Posts: 12026


If In Doubt, Cluster!


WWW
« Reply #8 on: December 10, 2004, 01:33:51 AM »

you need some alcohol
Logged

PeterJames
Space Explorer
***
Offline Offline

Posts: 6


WWW
« Reply #9 on: June 03, 2005, 02:49:09 PM »

Quote from: checkup
This is useful. Thumbs Up

Seems to work for main page, but did not work for this case:

Page on web site is: TrialBSCbscr.htm


 I have worked out a system that will always redirect the url typed in to the best match. - and will work for your case

So /TeSt_ThIs would be directed to Test_this, or to TEST_THIS or whichever is on your site.

Truncated urls will also be redirected to the nearest match.

so /thishouldbeapage  is redirected to /thishouldbeapage.html

Test it on my site by altering any URL capitalisation to see what you get.
http://www.peter-thomson.co.uk

You can download this from the Perl area of my site:
http://www.peter-thomson.co.uk/perl/index.html
Logged

Peter
Marce_22
Intergalactic Superstar
*****
Offline Offline

Posts: 196


WWW
« Reply #10 on: June 08, 2005, 04:27:52 PM »

Thanks for the link, Peter!

However, I do find it some-what annoying and pointless that I have to "register" to access the download. I'm not quite too sure why you have it like this, especially since you can just put any giberish you want in the fields and you can still access the downloads... Either way, good work and thanks!
Logged

Surfing the Net at work? Don't get caught! Download Instant Hidden Internet!

Want to rename files, folders MP3s, WMAs, convert images & edit date & time stamps and file attributes? Download Name and Property Modifier!


Visit MAGNONIC SOFTWARE for more programs!
DiFFereNT
Newbie
*
Offline Offline

Posts: 1


« Reply #11 on: February 09, 2006, 12:16:41 PM »

I realize this discussion is old, but thanks to Google I just found it.

For some reasons, I am not able to get Peter's PHP/Perl scripts to work.
Instead, I receive an Internal Server Error 500 when trying to access any path with the incorrect case.
===========================================================
And if it helps, here is the URL it displays in the address bar when I get the 500:

http://www.domain.com/cgi-bin/error.pl?request=http://www.domain.com/photos/BillGates/Google/
Of course, the last URL is what I typed. The actual folder names are:
http://www.domain.com/PHOTOS/BillGates/Google
============================================================
And here is the error:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
============================================================
Help would be greatly appreciated.

Thanks
« Last Edit: February 09, 2006, 12:22:23 PM by DiFFereNT » Logged
cemedia
Spaceship Captain
*****
Offline Offline

Posts: 124


WWW
« Reply #12 on: August 18, 2006, 10:19:15 AM »

Stepping back to the first post (topic starter)

you know that this is a great feature that the LP servers are case sensitive

lets say you have a admin.php at /admin like most sites

if the folder is /ADMIN you will have less people who will try to get access as /admin will give them a error page, 99% will never try /ADMIN

Logged

Mike Good
Newbie
*
Offline Offline

Posts: 2


« Reply #13 on: August 22, 2006, 10:42:25 AM »

I Know this is old but, I found it pretty helpful. I run a directory website and people type in wrong things all the time. Thanks for the link and Thread. See you around.
Logged

JamesG
Lager Ship
Berserker Poster
*****
Offline Offline

Posts: 12026


If In Doubt, Cluster!


WWW
« Reply #14 on: August 22, 2006, 10:44:48 AM »

glad it helped Smile
Logged

Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM