0

I'm working my php site, which is almost completed, but the thing is remaining that is Clean Url. like website.com/my-post or website.com/blogs/my-post.

I used php_slug function during posting the blog, and that works perfect slug url is created in sql database. But I don't know how to pick that using php code. I already tried .htaccess file..

My php slug code

function php_slug($string) {
    $spl_char = '/[^\-\s\pN\pL]+/u';
    $double_char = '/[\-\s]+/';

    $slug = preg_replace('/[^a-z0-9-]+/', '-', strtolower($string));

    $slug = trim($string, '-');

    return $slug;
}

my .HTACCESS code is

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^\.]+)$ $1.php [L,QSA]

RewriteRule ^article([a-zA-Z0-9-/]+)$ article.php?article_link=$1 [L,QSA]
RewriteRule ^article([a-zA-Z0-9-/]+)/ article.php?article_link=$1 [L,QSA]

I'll be very happy to get solution for this problem

Martin Heralecký
  • 5,649
  • 3
  • 27
  • 65

0 Answers0