force redirect?!

New to mod_rewrite? This is a good place to start.

force redirect?!

Postby BMN » Thu Feb 10, 2011 9:01 am

Hi there, i just setup a subdomain "".
Now i want to track my page with an analytic-tool - this is functional with this structure:
- i only share links on the internet with the url to e.g. ""
- this page includes a 404.php, in which the javascript of the analytic-tool is in it - this 404.php redirects to ""

So, normally this is, what i want! BUT: if someone shares the link on his own, he will share it with the subdomain and then the javascript won't be run und i can't track my visitors, 'cause the directlink...

Now i want to fix this problem with mod_rewrite, that on demand of e.g. "" the user gets redirected to "" - then the 404.php gets included and the anayltic-tool tracks this visitor - to exit the loop mod_rewirte should only fire on a referer that is not

This is my test-code in .htaccess (without referer-check but thats simple, i hope :D)

Code: Select all
    RewriteEngine on
    Redirect 301 /**

Easy code, but this is only functional on links, they're not exists. How i can realize, that mod_rewrite forces redirecting, so long the referer is not

My problem simply described: --> referer != --> --> include javascript --> (referer =, so no more redirect!)

Thanks in advance!
Posts: 39
Joined: Wed Jul 05, 2006 2:15 am

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 10 guests