如何使用htaccess使个人资料链接看起来像Facebook


How to use htaccess to make profile links look like Facebooks

我想知道如何配置.htaccess文件以呈现以下格式的配置文件页面:firstname.lastname.id。有点像Facebooks个人资料链接的样子,如果有人知道如何制作,我会非常感激的!:)

PS。抱歉你解释不好!我是瑞典人!

php_flag magic_quotes_gpc off
AddType 'text/html; charset=UTF-8' html
Options -Indexes -MultiViews
RewriteEngine on
# list of extensions which won't be running the index.php file
RewriteCond %{REQUEST_URI} !(.*)'.(css|js|gif|jpg|png|txt|ico)$
# everything else will run index.php file, where you can check your URL string if it matches any of your user profile name
RewriteRule .* index.php

然后在php:中

$requestedURL = 'first_name.last_name.23423';
$matches = array();
$res = preg_match_all('/([a-zA-Z0-9_]+).([a-zA-Z0-9_]+).('d+)/', $requestedURL, $matches);
echo "<pre>";
var_dump($matches);
echo "</pre>";
die();

其中$matches为:

array(4) {
  [0]=>
  array(1) {
    [0]=>
    string(26) "first_name.last_name.23423"
  }
  [1]=>
  array(1) {
    [0]=>
    string(10) "first_name"
  }
  [2]=>
  array(1) {
    [0]=>
    string(9) "last_name"
  }
  [3]=>
  array(1) {
    [0]=>
    string(5) "23423"
  }
}