dclaudiud
dclaudiud

Reputation: 334

httpd.conf proxypass rewrite

I am trying to use the proxy only if the request comes from VLC player, so in the request header the user-agent would contain VLC.

<Directory "/var/www/html/mvs">
RewriteEngine On
RewriteCond expr "%{HTTP_USER_AGENT} -strmatch '*VLC*'"
RewriteRule ^mvs/(.*)$  http://www.example.com/directory/$1  [P]
ProxyPassReverse /mvs/ http://www.example.com/directory/
</Directory>

When I run a file in VLC web plugin which is located in /var/www/html/mvs/ it plays, so I think that the RewriteRule and the RewriteCond are wrong. The file should not play because the file does not exist on the http://www.example.com/directory/ folder. I don't know how to debug this. Sry

Upvotes: 1

Views: 1144

Answers (1)

dclaudiud
dclaudiud

Reputation: 334

I figured it out. I wrote the following lines in the .htaccess file placed in the html directory:

Options +FollowSymLinks
RewriteEngine On
RewriteCond  %{HTTP_USER_AGENT}  ^VLC
RewriteRule  ^mvs(.*) http://188.25.221.87$1 [R,L]

If the user-agent contains VLC, and tries to access the /html/mvs/ directory he is being redirected to http://188.25.221.87/ and the path or query after /mvs/ is copied. If the user agent does not contain VLC the user is not redirected. Important %{HTTP_USER_AGENT} ^ is case sensitive, so it would not have worked with ^vlc.

Upvotes: 1

Related Questions