只是用户发送的所有页面都是基于另一个 php 文件旋转的。
假设用户(假设用户名是john
)发送了文件foo.html
要访问该文件foo.php
,需要访问这样的 URL:
john.site.com/partners.php?path=foo.html
[固定的]
使用.htaccess (mod rewrite)
,您可以对其进行修改URL
,使其看起来像这样:
john.site.com/foo.html
只有子域可以访问 php 文件partners.php
(应该是根)
mod_rewrite/.htaccess:
http ://www.sitepoint.com/guide-url-rewriting/
[编辑]
例子:
.ht 访问:
RewriteEngine On
RewriteRule ^/([A-Za-z0-9\/\-_. ]+)$ /partners.php?path=$1
PHP代码:
include('youscript.php');
//Get username
$tmp = $_SERVER['HTTP_HOST'];
$tmp = explode('.',$Q);
$username = $test[0];
//Print file in page
if(isset('users/'.$username.'/'.$_GET['path'])){
echo file_get_contents('users/'.$username.'/'.$_GET['path']);
}
结果:
paul.site.com/partners.php?path=mypage.html
至
paul.site.com/mypage.html
john.site.com/partners.php?path=folder1/mypage.html
至
john.site.com/folder1/mypage.html
william.site.com/partners.php?path=css/style.css
至
paul.site.com/css/style.css