2011-11-20 47 views
1

我的问题:我想有一个rewriteRule,允许我将参数转发到我的服务器上的另一个目录。我调用了我的页面的一个子域,这个子域应该指向我的根页面的“普通”目录。该规则应该为所有将被调用的url添加一个参数。子域RewriteRule将URL Params传输到其他目录?

例子:

Root-Page: http://www.example.com -> directory on the server /srv/www/vhosts/example.com/httpdocs/ 

Subdomain: http://fb.example.come 

现在根页和子域应指向同一个目录:

子域 - >目录服务器上/srv/www/vhosts/example.com/的httpdocs/

两个域之间的区别是,应添加到每个URL调用paramenter:

User-Call: http://fb.example.com/index.php 
--> add a fb=1 param 
Intern -> http://fb.example.com/index.php?fb=1 

User-Call: http://fb.example.com/show.php?param=1&test=1 
--> add a fb=1 param 
Intern -> http://fb.example.com/show.php?fb=1&param=1&test=1 

URL中始终应该有一个名为“fb = 1”的参数。

我该如何认识到这一点?

+0

可能是webmasters.stackexchange.com比这里更好的问题。 –

回答

0
RewriteCond %{QUERY_STRING} !fb=1 
RewriteCond %{HTTP_HOST} ^fb\. 
RewriteRule (.*) $1?fb=1 [QSA] 

但我只想把一些代码在你的PHP检测fb.example.com域。更清洁

if($_SERVER["HTTP_HOST"]=="fb.example.com") 
    $fb = true; 
相关问题