Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat to do with a community URL style like Last.FM or Wikipedia?
    text
    copied!<p>I'm trying to understand how I should work with characters in <code>URLs</code>, this because I'm building a site where the user can store content and go to the content's page by digiting it's name in the <code>URL</code>.</p> <p>so, something like <code>Wikipedia</code> or <code>Last.FM</code> website.</p> <p>I see in the site, user can write something like<br/><code><a href="http://it.wikipedia.org/wiki/Trentem%C3%B8ller" rel="nofollow noreferrer">http://it.wikipedia.org/wiki/Trentemøller</a></code> and the page of the artist can reached.<br/></p> <p>after the page is loaded, if I copy the URL i see written as:<br/><code><a href="http://it.wikipedia.org/wiki/Trentem%C3%B8ller" rel="nofollow noreferrer">http://it.wikipedia.org/wiki/Trentemøller</a></code> but if I paste it into a text editor, it will be pasted as<br/> <code><a href="http://it.wikipedia.org/wiki/Trentem%C3%B8ller" rel="nofollow noreferrer">http://it.wikipedia.org/wiki/Trentem%C3%B8ller</a></code></p> <p>so the char <code>ø</code> is pasted as <code>%C3%B8</code></p> <p>of course the same is for URLs like this (the page of the artist Takeshi Kobayashi)</p> <p><code><a href="http://www.last.fm/music/%E5%B0%8F%E6%9E%97%E6%AD%A6%E5%8F%B2" rel="nofollow noreferrer">http://www.last.fm/music/小林武史</a></code><br/> <code><a href="http://www.last.fm/music/%E5%B0%8F%E6%9E%97%E6%AD%A6%E5%8F%B2" rel="nofollow noreferrer">http://www.last.fm/music/%E5%B0%8F%E6%9E%97%E6%AD%A6%E5%8F%B2</a></code></p> <p>If I digit the first or the second, the page works in any case, why?</p> <p>I think I should do something with the <code>.htacces</code> and <code>mod_rewrite</code> but I'm not sure, are the special chars automatically converted to the url special chars?</p> <p>and then, how can I do to let PHP do the right query with the content name?</p> <p>if I have a table like</p> <pre><code>table_users - username - age - height - weight - sex - email - country </code></pre> <p>I'm able with <code>mod_rewrite</code> to write an address like <code><a href="http://mysite.com/user/bob" rel="nofollow noreferrer">http://mysite.com/user/bob</a></code> to get the <code>username</code> bob from the <code>table_users</code> but what about <code><a href="http://mysite.com/user/%E5%B0%8F%E6%9E%97%E6%AD%A6%E5%8F%B2" rel="nofollow noreferrer">http://mysite.com/user/小林武史</a></code>?</p> <p>here I show a simple example of what I think to do:</p> <pre><code>#.htaccess RewriteEngine On RewriteRule ^(user/)([a-zA-Z0-9_+-]+)([/]?)$ user.php?username=$2 &lt;?php // this is the page user.php // this is the way I use to get the url value print $_REQUEST["username"]; ?&gt; </code></pre> <p>this works, but it's limited to [a-zA-Z0-9_+-], how to be more compatible with all chars like the others without loss too much security?</p> <p>Did someone know some way to avoid troubles?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload