Forum Moderators: phranque
I don't know if this can be done in htaccess, but here goes ...
I have a web site where you can request to see a video. When you select your video my scripts create your video in a public directory using your IP address as part of the file name. As an example, if i were to request a video the video would be named "www.mysite.com/videos/70.32.9.115.rm".
Here is what i'm trying to do: Is there some way to write an htaccess file so that the requesters IP address is automatically matched up with the correct video? In other words, using the web address above, i'd like to be able to type "www.mysite.com/videos/" into my browser and have an htaccess file automatically forward me to the video file named after my IP address. Conversely, it would be nice if the htaccess file would recognize when a file named after my IP address does not exist and forwards the user back to the video request page.
Any ideas? I've been working on this for hours and i don't have a clue.
Paul
This sounds like a very simple application of mod_rewrite to insert the variable %{REMOTE_ADDR} into the requested URL, and serve the request from the resulting location. If you are already using mod_rewrite, then it's one line of code:
RewriteRule ^/videos/video\.rm$ /videos/%{REMOTE_ADDR}.rm [L]
Reference documents for mod_rewrite are cited in our forum charter [webmasterworld.com].
Jim
AuthUserFile /dev/null
AuthGroupFile /dev/null
RewriteEngine On
RewriteRule ^/test/some.gif$ /test/%{REMOTE_ADDR}.gif [L]
I also tried it with the back slash like this:
AuthUserFile /dev/null
AuthGroupFile /dev/null
RewriteEngine On
RewriteRule ^/test/some\.gif$ /test/%{REMOTE_ADDR}.gif [L]
But no go. The problem is the "%{REMOTE_ADDR}." is not being translated into a remote address. It comes out exactly as written: %{REMOTE_ADDR}.
I'll keep hammering away at it.
Paul
AuthUserFile /dev/null
AuthGroupFile /dev/null
RewriteEngine On
RewriteRule ^test/some\.gif$ /test/%{REMOTE_ADDR}.gif [L]
Jim