1

My problem: I want to have a rewriteRule that allows me to forward parameter to another directory on my server. I called a subdomain of my page and this subdomain should points on the "normal" directory of my root page. Addional to that the rule should add a parameter to all url's that will be called.

Example:

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

Subdomain: http://fb.example.come 

Now the Root-Page and the Subdomain should point to the same directory:

Subdomain -> directory on the server /srv/www/vhosts/example.com/httpdocs/

The difference between both domains is a paramenter that should add to every URL call:

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

There should always be a param called "fb=1" in the URL.

How can i realize this?

John Conde
  • 217,595
  • 99
  • 455
  • 496
elchueko
  • 439
  • 1
  • 6
  • 20

1 Answers1

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

But I would just put some code in your php to detect the fb.example.com domain. Much cleaner

if($_SERVER["HTTP_HOST"]=="fb.example.com")
  $fb = true;
Gerben
  • 16,747
  • 6
  • 37
  • 56