SEO friendly URLs for a multi-language site

I have a website that I create using php, which will allow you to use several languages ​​for content. One part of the site will have listings of companies. I have SEO friendly URL settings for viewing these lists, so for example, I will have a business listing called "Bar down the street." The url will look like this:

/listing/a-bar-down-the-street

However, let's say there is an Arabic version of this list, then the name will look like this:

شريط أسفل الشارع

How can I do this in the same URL as the English version, but in the language it is currently in? When I tried my function in the Arabic version, which turns the string into a friendly URL, it returns empty.

EDIT: To clarify, all I'm looking for is a php function that allows me to turn any string into an SEO friendly URL no matter what language this site is in.

EDIT PART 2 The following is an Im function that uses to rewrite a string into an SEO friendly URL. Perhaps you can tell me what I need to add in order to make it a language?

    public function urlTitle($str,$separator = 'dash',$lowercase = TRUE)
    {

        if ($separator == 'dash')
        {

            $search     = '_';
            $replace    = '-';

        }else
        {

            $search     = '-';
            $replace    = '_';

        }

        $trans = array(
                        '&\#\d+?;'              => '',
                        '&\S+?;'                => '',
                        '\s+'                   => $replace,
                        '[^a-z0-9\-_]'          => '',
                        $replace.'+'            => $replace,
                        $replace.'$'            => $replace,
                        '^'.$replace            => $replace,
                        '\.+$'                  => ''
                        );

        $str = strip_tags($str);
        $str = preg_replace("#\/#ui",'-',$str);

        foreach ($trans AS $key => $val)
        {

            $str = preg_replace("#".$key."#ui", $val, $str);

        }

        if($lowercase === TRUE)
        {

            $str = mb_strtolower($str);

        }

        return trim(stripslashes($str));

    }
+3
source share
3 answers

I found a similar discussion in an existing SO discussion . It seems that what you are requesting should be possible out of the box.

-, , , seo-friendly URL- , url.

- ?

UPDATE , - :

'[^a-z0-9\-_]'          => '',

, -z . , , , , .

, URL- - , URL-.

. :

URL- , , , . , . . , , فنادق. , , Chrome - http://www.xn--mgbq6cgr.com/.

, URL-, , , .

- -, , , , , url.

+1

, , php-:

'[^a-z0-9\-_]'          => '',

strtolower :

$str = mb_strtolower($str,'UTF-8');

. - , ? ? , URL? , php 5.3, php. , , , 5.2x.

0

, , , ([^a-z0-9\-_]) UTF-8. : [^\p{L}0-9\-_]

, , : SEO- URL- PHP url_slug()

0

All Articles