Search code examples
.htaccessslug

How to enable arabic slug in htaccess?


I have a multi-languages website, and I'm trying to create a friendly URL. In my database, I have the slug field. When the article's title is in english the slug appear in url and redirection works fine. but when the title is arabic the slug appear and the redirection shows "Object not found" page.

what seems to be the problem guys ? please help I'm stack.


Solution

  • Most likely the issue is your rewriting rule. It explicitly is crafted such that it only gets applied for requests that consist of only ASCII characters, an underscore or a hyphen in the slug part of the URL. That obviously won't match arabic characters in the URL. So you have to change your rule to accept more or less anything expect very special characters:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^([0-9]+)/([^/]+)/?$ article.php?id_art=$1 [NC,L]