skip to Main Content

Well Im cracking my head with this. I’m using SEO friendly url in my php mysql project, and everything works fine until accents or ñ’s appear. An example of this would be the word “año” or “río”, that gives me as an error message:

Not Found

The requested URL /año and URL /río/

Conexion.php

$db = new PDO('mysql:host='.$db_host.';dbname='.$db_database, $db_user, $db_pass);$db->exec("set names utf8");

My DB Collation is:

utf8_general_ci

The url to project.php looks like this:

http://www.mywebsite.cl/año

project.php (File who gets the data and throw me strange chars like año or /río/ )

<meta charset="utf-8" />

$result->execute(array($_GET['project']));

.htaccess

AddDefaultCharset utf-8
RewriteRule ^([0-9a-zA-Z-]+)/$ project.php?work=$1

Thanks.

2

Answers


  1. It is my understanding that URI’s really should not have "foreign" / unicode characters in them, and that you should stick to ASCII characters.

    https://www.rfc-editor.org/rfc/rfc3986#section-2

    The most thorough way that I have seen people handle this issue is to create a copy of each URL at both URL’s. For example example.com/úrl and example.com/url where the former actually redirects users to the latter. I think this would likely have to be done via htaccess or something similar. And for SEO purposes you would want to use canonical so that you don’t get marked down for duplicate content.

    Of course this was my understanding as of a few years ago and unicode characters are becoming more common so things may have changed.

    Login or Signup to reply.
  2. Internationalised Domain Names (IDN) allow the use of non-ASCII characters in URLs. This is done by translating a string containing non-ASCII characters into an ASCII interpretation known as Punycode and prepending the 4-char string "xn--" to distinguish it from normal ASCII.

    For example, navigating to the following IDN would resolve to español.com (the last 3 characters denote the special character and its location):

    xn--espaol-zwa.com
    

    Internationalized Resourced Identifiers (IRI) are the equivalent adaptation of URLs (see RFC 3987).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search