Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

arabic query string - url did not stored and displayed

Tags:

url

php

seo

I'm trying to make my links SEO friendly by addingdate and title. However, I some of the titles are in Arabic. The English ones work great, while the Arabic ones doesn't. Example:

خالد-على-20120923220529.html

Following this tutorial, I've produced this code:

$title=mysql_real_escape_string($_POST['title']);

i have error with insert title and URL didn't insert with Arabic character and when removing this code inserting done no problem but when select this url from database will redirect not found 404 i need t display my links

http://dzeduc.org/%D8%A7%D9%84%D9%85%D8%B9%D8%A7%D8%AF%D9%84%D8%A7%D8%AA-%D9%88-%D8%A7%D9%84%D9%85%D8%AA%D8%B1%D8%A7%D8%AC%D8%AD%D8%A7%D8%AA-%D9%85%D9%86-%D8%A7%D9%84%D8%AF%D8%B1%D8%AC%D8%A9-1%D9%882/

How can i resolve this problem?

Note

$conn = mysql_connect($db_host,$db_user,$db_pass) or die(mysql_error());
mysql_select_db($db_name,$conn);

mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 

Meta Tags

<meta charset="UTF-8" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" /> 
like image 392
Afro Gfx Avatar asked Oct 31 '12 12:10

Afro Gfx


1 Answers

You should fix 3 problems :

1. Edit your code on Article.php to:

$url = urldecode( mysql_real_escape_string($_GET['url']) );

2. Make sure your url field collation is utf_general_ci

3. Edit your .htaccess file to:

RewriteEngine On

RewriteRule ^(.*).html$ article.php?url=$1
like image 126
DJafari Avatar answered Oct 17 '22 01:10

DJafari