views:

37

answers:

1

I'm trying to do a rewrite where I need the host part of the HTTP_REFERER.

So if the referer is e.g. http://www.example.com/some/path I need to extract the host part, www.example.com and use it in the RewriteRule, so that it rewrites to /some/serverpath/www.example.com/subfolder.

Is this possible?

+2  A: 

Try this:

RewriteCond %{HTTP_REFERER} ^https?://([^/:]+)
RewriteCond %{REQUEST_URI} !^/some/serverpath/
RewriteRule ^ /some/serverpath/%1/subfolder
Gumbo