Link to home
Start Free TrialLog in
Avatar of Dodger42
Dodger42

asked on

Mod-rewrite question: convert static URL to dynamic for dynamic signatures

Hey there, I want to create a mod_rewrite rule to allow dynamic signatures.

Here is the client URI: http://www.somesite.com/pilot1.png
Here is the rewritten URI: http://www.somesite.com/sigs/sig.php?id=pilot1.png

Also please include which .htaccess file(s) needs modifying.

Thanks.
Avatar of Dodger42
Dodger42

ASKER

No response so points bumped up.


if you want it for png extension only, you can try something like :


RewriteRule ^(.*)\.png$  http://www.somesite.com/sigs/sig.php?id=$1\.png
more info on  url rewriting:
http://rosebud.stanford.edu/manual/misc/rewriteguide.html
Ok that redirect is kind of working, but there is an extra slash in there after the = sign:

http://192.168.0.250/sigs/sig.php?id=/42SF-Dodger

"/42SF-Dodger" should be "42SF-Dodger"
ASKER CERTIFIED SOLUTION
Avatar of Tol_cv
Tol_cv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One more thing. If I only want this rule to take place if the request is in the / directory, do I just put that rule int he directory section for /?

Thanks
you can use:

RewriteRule ^/(.+[^/])\.png$  http://www.somesite.com/sigs/sig.php?id=$1\.png
(.+[^/])  where  matches everything , exept string that contains /

it doesn't help to use  RewriteRulele  ^/(.*)\.png$  http://www.somesite.com/sigs/sig.php?id=$1\.png   in <directory> section.   A rule is used in non-server context  if you add it to  a .htaccess file.