The MU forums have moved to WordPress.org

Case sensitivity of username in blog url (7 posts)

  1. metaface
    Member
    Posted 16 years ago #

    Hello,

    I have an WPMU installation that uses subdirectories instead of subdomains. I would like blog usernames in URLs to not be case senstive.

    Consider a WPMU blog located here:

    http://www.mysite.com/blogs/someuser

    I would like to have it so that the same blog could be accessed with an address like:

    http://www.mysite.com/blogs/SomeUser

    or

    http://www.mysite.com/blogs/SOMEUSER

    If I attempt to capitalize the username in the URL now, it loads the correct blog theme but I get a "Not Found" error where the content should be.

    Could someone please advise in what part of the code WPMU gets the username from the URL and does a database query with it?

    My intent is to first do a strtolower() before comparing it with the data in the database.

    I have examined this plugin:
    http://n0tablog.wordpress.com/my-wordpress-plug-ins/insensitive/

    But I'm not sure if it will work with WPMU or if it does what I want.

    I'm not trying to have case insensitve logins (because we are using an external authentication system) but I am trying to have case insensitive URLs.

    Any thoughts?

    Thank you.

    -Dave

    Using capital

  2. drmike
    Member
    Posted 16 years ago #

    I would like to have it so that the same blog could be accessed with an address like:

    Hmmm, I could have sworn that the webserver should drop to all lowercase but that's for subdomains, not subdirectories.

    wp-includes/wpdb.php maybe? I'd have to think about that one.

  3. metaface
    Member
    Posted 16 years ago #

    While examining the code for the function wp_login I noticed the following:

    The wp_login() function in /wp-includes/pluggable.php does NOT convert the username to lowercase before authentication.

    The wp_login() function in /wp-content/mu-plugins/pluggable.php DOES convert the username to lowercase.

    (see the strtolower() on line 6 in /wp-content/mu-plugins/pluggable.php)

    Is there any reason why both wp_login() functions shouldn't first convert the username to lower case?

    Thanks,
    Dave

  4. kingler
    Member
    Posted 16 years ago #

    pluggable.php contains functions that can be overridden by plugins. So I assume this is a consideration of the core developers to leave most things pluggable if you need to.

    This way you can safely change only the pluggable functions to achieve the functionalities you need, while leaving the core PHP files intact. It is the beauty of WP, isn't it? :)

  5. metaface
    Member
    Posted 16 years ago #

    I understand that those functions can be overriden with a function.

    In this case, I am simply trying to determine what part of WPMU needs to be modified (through a plugin or other means) in order to accomplish case-insensitive URLs.

    I can't seem to find where it gets the username from the URL.

    I simply want to do a strtolower() on that value.

    -Dave

  6. drmike
    Member
    Posted 16 years ago #

    I can't seem to find where it gets the username from the URL.

    Should do that during activation actually as that's the only time a blog is created where it's matched up with the username. if you create a blog later on, it's got to have a different name.

  7. metaface
    Member
    Posted 16 years ago #

    I figured it out (mostly). Maybe this will be useful to someone...

    The username used in the blog URL is stored in multiple places within WPMU.

    For example, let's say there's blog ID 123 which has a URL of:

    http://www.mysite.com/blogs/TheUsername/

    When you load the home page of this blog, TheUsername is stored (inside of a URL) in the wp_123_options table in the option_value where option_name = 'home'.

    Here is a list of the places in the WPMU database where the username is stored and used in URLs:

    • wp_options.option_name = 'home'
    • wp_options.option_name = 'siteurl'
    • wp_options.option_name = 'fileupload_url'
    • wp_users.user_login
    • wp_users.user_url
    • wp_blogs.path

About this Topic

  • Started 16 years ago by metaface
  • Latest reply from metaface