Cydewinder Posted February 1, 2008 Share Posted February 1, 2008 I've got a system where every image on my server has a watermarked version cached. If the file is test.gif, the watermark is test_wm.gif At the moment every request for an image gets sent to a php file which serves up the cached version or makes a new one if there isn't a cached version using this line in htaccess. This works fine. RewriteRule ^(.+).gif$ wm.php?src=$1.gif Last night I was playing around trying to get it to redirect based on whether the file exists or not, and then mysteriously everything stopped working. So I started stripping it back and trying to find what the problem was. Now, even this rule does not work. RewriteRule ^(.+).gif$ $1_wm.gif It serves up a broken image instead of the watermarked one. Yet, this rule works as intended. RewriteRule ^(.+).gif$ $1.gif Is there something obviously wrong with my rule that I'm just not seeing because I've been staring at it too long? Or should I be talking to my host about a messed up apache? Quote Link to comment https://forums.phpfreaks.com/topic/88823-rewrite-mysteriously-not-working/ Share on other sites More sharing options...
madmax Posted February 1, 2008 Share Posted February 1, 2008 Very difficult to say - what might be likely is that you have another ruleset which is acting on this one unintentionally The best way to debug is to enable rewrite logging - use tail -f (Windows or Linux) and watch the log-end sequence If the rewrite appears to rewrite the URI correctly with no interference from other rules you can then also watch the access/error logs using tail to see what actual file "hits" the server is seeing. If there are cache or improper filename problems then you may see this in the error log. You may need RewriteLogLevel 5 or higher and it may help if you're really stuck to set Apache log level to debug briefly Don't forget to disable rewrite logging after and reset any debug log levels back down to normal. I assume you're using Apache 2.3 (or 2.2??) with Apache cacheing. Never used it myself I use Apache 2.0 and wrote my own cache module when I needed it using mod_rewrite so not sure what problems the cache age etc. might add to this. Might be worth disabling cacheing until the rewrite is solid. Quote Link to comment https://forums.phpfreaks.com/topic/88823-rewrite-mysteriously-not-working/#findComment-454932 Share on other sites More sharing options...
hackerkts Posted February 1, 2008 Share Posted February 1, 2008 Maybe you can try using (.*) instead of (.+), if you say your RewriteRule ^(.+).gif$ wm.php?src=$1.gif isn't working, then try to echo the value of $_GET['src']. Quote Link to comment https://forums.phpfreaks.com/topic/88823-rewrite-mysteriously-not-working/#findComment-454934 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.