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, 2022 in Others by Kichu
• 19,050 points
407 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, 2022 by narikkadan
• 63,420 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, 2022 in Others by narikkadan
• 63,420 points
467 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, 2022 in Others by narikkadan
• 63,420 points
302 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, 2022 in Others by narikkadan
• 63,420 points
809 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, 2022 in Others by narikkadan
• 63,420 points
389 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, 2022 in Others by narikkadan
• 63,420 points
5,077 views
0 votes
1 answer

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

google bot will find  it if you ...READ MORE

answered Feb 11, 2022 in Others by narikkadan
• 63,420 points
345 views
0 votes
1 answer

Create an seo and web accessibility analyzer

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

answered Feb 12, 2022 in Others by narikkadan
• 63,420 points
296 views
0 votes
1 answer

Simple question regarding PHP, Wordpress & Yoast SEO

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

answered Feb 14, 2022 in Others by narikkadan
• 63,420 points
325 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, 2022 in Others by narikkadan
• 63,420 points
366 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, 2022 in Others by narikkadan
• 63,420 points
1,195 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP