Search code examples
apache.htaccesshttp-redirectraspberry-piwebcam

Redirect from subfolder to main domain with different port


For christmas i got a raspberry pi and i want it to use it among other things as a ip cam. So i googled how to use a webcam and found a tutorial how to use motion. Worked all fine.

Now i have the follwing "problem":

I can access the webcam via <domain>:1337. But i want to access the webcam via <domain>/webcam.

I googled some stuff about htaccess but i couldn't solve the problem since i'm fairly new to the htacces stuff.

I actived htaccess in /etc/apache2/sites-enabled/000-default and created a . htaccess file in /var/www/.

Any idea what to write to the htacces file or how to tell motion to be available in the subfolder?

Thank you in advance!


Solution

  • Put this code in your htaccess

    RewriteEngine On
    
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^webcam$ http://<domain>.com:1337/ [P]
    

    Note: make sure mod_rewrite and mod_proxy are enabled