Monday, February 21, 2011

Rewrite only a specific file using MOD_REWRITE

I have a file that can be reached using multiple paths:

http://mydomain.com/portal1/movie.swf
http://mydomain.com/portal2/movie.swf
http://mydomain.com/portal1/substep/movie.swf
etc.

I want a rewrite rule to get this specific file from the following path:

http://mydomain.com/movie.swf

How can I do that?

From stackoverflow
  • in .htaccess in your main folder:

    RewriteRule ^portal.*movie\.swf$ /movie.swf [L]
    

    (backlash before the dot added after Gumbos comment. +1)

    Scharrels : I don't want to specify a rule for every possible path. Can I rewrite alle movie.swf's to /movie.swf using 1 rule?
    Scharrels : Never mind - your solution worked. I used RewriteRule ^.*/movie.swf$ /movie.swf [L]
    Gumbo : Don’t forget to escape the `.` character.

0 comments:

Post a Comment