Generate SEO friendly URLs slugs

0 votes
I have developed a photo sharing website in that i need a function to automatically create slugs and keep readable urls
Feb 13 in Others by Kichu
• 16,850 points
38 views

1 answer to this question.

0 votes
function format_uri( $string, $separator = '-' )
{
    $accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i';
    $special_cases = array( '&' => 'and', "'" => '');
    $string = mb_strtolower( trim( $string ), 'UTF-8' );
    $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string );
    $string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) );
    $string = preg_replace("/[^a-z0-9]/u", "$separator", $string);
    $string = preg_replace("/[$separator]+/u", "$separator", $string);
    return $string;
}

use this code and you will be able to create the slugs
answered Feb 14 by narikkadan
• 7,860 points

Related Questions In Others

0 votes
1 answer

Creating SEO friendly urls using htaccess

its just a simple step just use ...READ MORE

answered Feb 20 in Others by narikkadan
• 7,860 points
21 views
0 votes
1 answer

Googlebot is accessing .aspx pages, it should access SEO-friendly URLs only

the url mapping would be wrong that ...READ MORE

answered Feb 20 in Others by narikkadan
• 7,860 points
38 views
0 votes
1 answer

How can I create custom SEO-friendly URLs in OpenCart?

Index: catalog/controller/common/seo_url.php =================================================================== --- catalog/controller/common/seo_url.php (old) +++ catalog/controller/common/seo_url.php ...READ MORE

answered Feb 21 in Others by narikkadan
• 7,860 points
23 views
0 votes
1 answer

Googlebot is accessing .aspx pages, it should access SEO-friendly URLs only

the URL mapping you have done would ...READ MORE

answered Feb 24 in Others by narikkadan
• 7,860 points
54 views
0 votes
1 answer

How to use $_GET parameter to make seo friendly urls?

What you can do is the following RewriteEngine ...READ MORE

answered Feb 27 in Others by narikkadan
• 7,860 points
29 views
0 votes
1 answer
0 votes
1 answer

Create an seo and web accessibility analyzer

there are some tools which  are already ...READ MORE

answered Feb 12 in Others by narikkadan
• 7,860 points
49 views
0 votes
1 answer

Simple question regarding PHP, Wordpress & Yoast SEO

the way the search engine displays your ...READ MORE

answered Feb 14 in Others by narikkadan
• 7,860 points
26 views
0 votes
1 answer

Generate SEO friendly URLs- Slugs

// source: https://code.google.com/archive/p/php-slugs/ function my_str_split($string) { ...READ MORE

answered Feb 22 in Others by narikkadan
• 7,860 points
40 views
0 votes
1 answer

How does Stack Overflow generate its SEO-friendly URLs?

/// <summary> /// Produces optional, URL-friendly version of ...READ MORE

answered Feb 28 in Others by narikkadan
• 7,860 points
56 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP