Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts

    redirect a wong url to his lower case version

    for example, if the user writes http://myurl.com/TheFolder and it doesn't exist, redirect to http://myurl.com/thefolder. I can do it using javascript in the 404.shtml page, but I'm sure that there is a better & more intelligent way


    My server uses Apache. "Answer for dummies" please, I'm not very familiar with Apache & server languages / includes
    Don't resist to assimilation. Billions of Borgs can't be wrong!

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, seems that it can't be done. It was a nice idea
    Don't resist to assimilation. Billions of Borgs can't be wrong!

  • #3
    Regular Coder Feyd's Avatar
    Join Date
    May 2002
    Location
    Los Angeles, CA Maxim: Subvert Society
    Posts
    403
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The best option is mod_spelling, which will allow you to ignore case and have up to 'one misspelling' in a URL. It may be beyond your skills or access to the box, however. If it is already installed, try just sticking CheckSpelling on in an htaccess file for your site.

    Or you could make it conditional by checking to see if mod_spelling is available, and if it is turn it on:
    Code:
    <IfModule mod_speling.c>
      Checkspelling on
    </IfModule>
    You could do it (though not truly) through mod_rewrite in htaccess, but it would be pretty inefficient and be too heavy for what I would want to use...but it is doable.

    The real reasons you can't do it is that regex and substitution patterns need a per character pattern. Second, making them all upper or all lower case dynamically will not really help with case insensitive URLs, because the case that is typed in must access the case as it exists in the file-system (and making it all lc or all uc will not necessarily get the filename as it truly exists). Mod-spelling is the best way to go.

    Like I said, you could do it through mod_rewrite, but it would be extremely heavy and nasty...it would perform this extremely heavy and nasty check with EVERY SINGLE FILE ACCESS on your site (though you could make it semi-smart and order it not to check certain file types, but what about the case sensitivity of those file types?).

    The real and best way is to use all lowercase for your directories and file names, period.
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok thanks I will take a look at it

    In fact the situation is the following:
    I have a domain and offer a free subfolder for the customers that don't want to buy a domain name:

    mydomain.com/ramblabar
    mydomain.com/musicson
    ..and so on

    So if somebody writes i.e. RamblaBar, RAMBLABAR or RaMbLaBaR, I want the sistem to lowercase it (as I always use lowercase) and see if it exist, no need to check all the site looking for the specific file

    Now I'm using this javascript for the 404 page:
    <script>
    errurl='<!--#echo var="REQUEST_URI" -->'
    corrurl=errurl.toLowerCase()
    if (errurl!=corrurl) {self.location=corrurl} else {document.write('Error 404')}
    </script>

    It works fine, but don't looks very "professional"
    Don't resist to assimilation. Billions of Borgs can't be wrong!


  •  

    Posting Permissions

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