我想知道如何配置我的.htaccess文件以这种格式呈现配置文件页面:firstname.lastname.id。 排序Facebook的个人资料链接的样子,如果有人知道如何做到这一点,它将是非常appriciated! :)
PS。抱歉不好解释!我是瑞典人!
答案 0 :(得分:0)
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"
}
}