• Hello, in Admin, when I want to add a new category, I try to change the slug so I can keep the upper cases in the slug, but WP changes to lower cases. I know this is what WP is supposed to do, but I’d like to keep it in upper cases because I am trying to migrate a directory to WordPress that alreay have upper cases (see: https://www.perulinks.com/pages/english/Arts_and_Humanities/), and I can’t change the slug.

    Is there a way I can disable this? I read some posts about changing the code in wp-includes/formatting.php file and to do something with the “add_filter(‘sanitize_title’, ‘strtolower’)” but I don’t know exactly what to do.

    I’d appreciate any help. If I need to ad some code, please let me know in what file and where (e.g. line number) to change it.

    I tried to find a plug-in, but I don’t think there is anything available!

    THANKS IN ADVANCE!!!!

    CMA

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter orelweb

    (@orelweb)

    Just to clarify. This webpage is already indexed by Google since 2000 (yes it’s very old), and if I change the cases, my indexed pages will be dead. It’d be a SEO tragedy I think.

    Thanks again,

    CMC

    Thread Starter orelweb

    (@orelweb)

    I have found a possible solution to this problem (after spending long time).

    I modified the .htaccess file so the server can treat slugs in my domain the same.

    The solution is adding this code to the .htaccess file:

    RewriteEngine on
    RewriteBase /
    # force url to lowercase if upper case is found
    RewriteCond %{REQUEST_URI} [A-Z]
    # ensure it is not a file on the drive first
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule (.*) rewrite-strtolower.php?rewrite-strtolower-url=$1 [QSA,L]

    Source: https://www.simonholywell.com/post/2012/11/force-lowercase-urls-rewrite-php/

    I hope this won’t affect my SEO ??

    Thread Starter orelweb

    (@orelweb)

    Note that forces to lower case if Upper Case is found.

    It does not force Uper Case if lower case is found. I am sure there must be another .htaccess hack for that second case.

    Moderator bcworkz

    (@bcworkz)

    Sending requests to a PHP redirect file is a good solution because the PHP file is telling Googlebot and any other requester that the URL has permanently changed to all lowercase. (301 redirect) This is fine for SEO, the credit will transfer to the new, properly all lowercase version.

    The other side of problem is you need to change any links on your site that point to a mixed case resource to all lowercase. Eventually the search spiders will mostly stop trying to access the mixed case version, though it’ll take a while. The more difficult issue is the existing external links out there that are mixed case (other than search results). In some cases maybe you can get them changed, but in others it’ll be impossible. Eventually it shouldn’t matter much.

    I can’t imagine anyone needing to go the other way, but it’s just a matter of changing A-Z to a-z and using strtoupper() in the PHP file.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to keep Upper Cases in category slugs’ is closed to new replies.