1

In my website, For example:

**http://example.com/products/New-York/Coffee-Table/1**

to

**http://example.com/products/new-york/coffee-table/1**
Edwin Thomas
  • 1,186
  • 2
  • 18
  • 31

4 Answers4

5

PHP has a few built-in functions for converting string cases.

string strtolower ( string $string )

Returns string with all alphabetic characters converted to lowercase.
Note that 'alphabetic' is determined by the current locale. This means that e.g. in the default "C" locale, characters such as umlaut-A (Ä) will not be converted.

string strtoupper ( string $string )

Returns string with all alphabetic characters converted to uppercase.
Note that 'alphabetic' is determined by the current locale. For instance, in the default "C" locale characters such as umlaut-a (ä) will not be converted.

string mb_strtolower ( string $str [, string $encoding = mb_internal_encoding() ] )

Returns str with all alphabetic characters converted to lowercase.

string mb_strtoupper ( string $str [, string $encoding = mb_internal_encoding() ] )

Returns str with all alphabetic characters converted to uppercase.

string mb_convert_case ( string $str , int $mode [, string $encoding = mb_internal_encoding() ] )

Performs case folding on a string, converted in the way specified by mode.

--

Full documentation: http://php.net/docs.php

Community
  • 1
  • 1
Oka
  • 23,367
  • 6
  • 42
  • 53
3

You can do that in to .htaccess to force url to lowercase. Try this to your .htaccess file :

RewriteCond $1 [A-Z]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /${lowercase:$1} [R=301,L]
Eko Junaidi Salam
  • 1,663
  • 1
  • 18
  • 26
1

Use mb_strtolower($url). Use strtolower($url) if you are not concerned about non-ASCII characters in the URL. strtolower() mishandles multibyte characters.

Tomas Creemers
  • 2,645
  • 14
  • 15
0

Please use the inbuild PHP function strtolower() to convert your string to Lowercase.

$myUrl = "http://example.com/products/New-York/Coffee-Table/1";

$myModifiedUrl = strtolower($myUrl);

//$myModifiedUrl contents the string with lower case.

Hopefully you are looking for this.

Tamil Selvan C
  • 19,913
  • 12
  • 49
  • 70