是否可以使用php';s子域之上的无脂路由实现


Is it possible to use php's fat-free routing implementation ontop of subdomains?

假设我们有url:example.com

我们有一个子域,例如;link1.example.com>example.com/link1

添加路由"GET/link1"不起作用,它尝试转发到example.com/link1(是的,它尝试双斜杠),并且说重定向太多。

有人找到绕过这个的方法吗?

编辑:

如果我将.htaccess文件更改为以下文件:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.*)'.example'.co.uk
RewriteRule ^(.*)$ http://example.co.uk/$1 [L,NC,QSA]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L,QSA]
Options +FollowSymLinks -MultiViews -Indexes

然后,它根据我的意愿将其重定向到"example.co.uk/link1",但它更改了url,有没有一种方法可以在不更改url的情况下做到这一点?

您可以根据当前主机设置其他路由定义(并保持htaccess默认状态):

if ($f3->get('HOST')=='link1.example.com') {
  $f3->route('GET /',function(){
    echo "sub-domain page";
  });
} else {
  $f3->route('GET /',function(){
    echo "main page";
  });
}