Hi all.

Im looking for some help to setup a htaccess like below:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://www.aaa.com/
RewriteRule /* http://www.domain.com/aaa [R,L]
RewriteCond %{HTTP_REFERER} ^http://www.bbb.com/
RewriteRule /* http://www.domain.com/bbb [R,L]
RewriteRule ^(.*)\.html$ index.php?id=$1 [L]

I have the code above but no luck to do what I want
I need if the referer is aaa.com then it redirects to domain.com/aaa, then if the referer is bbb.com it redirects to domain.com/bbb, and finally if none of above are coming from aaa.com nor bbb.com it writes the friendly URL ( last line. )

It is working to redirect people based on the referer, but I cannot make it to work to re-write the URL for those not refered by aaa or bbb. It simple shows a 404 error obviously because the URL has not been re-written

I tried with [L] , [OR], [NC] and whetever combination with no luck, what is not a surprise since I know nothing about these parameters coz I couldnt find any tutorial about them in apache.org

Can someone help me out with it?
Im almost sure Im missing some parameter but cannot find which.

Thanks in advance

    Update:
    Now I noticed the code works perfect the .htaccess added to the public_html directory but it does not when placing it above the fold, say in the /vhosts dir level

    Its obvious it cannot re-write the friendly URL from this top location, is there any way to do that? May be adding the domain.com somewhere in the last line?

    How it should look?

      Write a Reply...