Hey guys!
I have an image gallery website, which i just recently upgraded to mod_rewrite, and now seeing a great increase in Googlebot&co activity
The links on my site look like this:
Display an image
/idsp/2008090519241505
actual: /scripts/idsp.cgi?id=2008090519241505
Display thumbnail gallery
/thmb/00/1700
actual: /scripts/thmb.cgi?ct=00;lp=1700;
ct = category, lp = list position (linked to page)
Using this in htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/idsp [NC]
RewriteRule ^idsp/?([0-9]+)?/?$ /scripts/idsp.cgi?id=$1; [NC,L]
RewriteCond %{REQUEST_URI} ^/thmb [NC]
RewriteRule ^thmb/?([0-9]+)?/?([0-9]+)?/?$ /scripts/thmb.cgi?ct=$1;lp=$2; [NC,L]
Now this works pretty nicely, it also matches /thmb/00 and /thmb only, in which case the script uses defaults for category and page.
The issue i have is that you can add as many slashes to the end as you like, and it still matches. This of course moves the generated page deeper and deeper into the folder tree, and me being a friend of relative urls, having implemented in my scripts a function to adapt them automatically so images and links work flawlessly no matter how many backslashes or in which folder depth the page is displayed, now find that when you add alot of these slashes, the relative paths in the generated page will be flooded with ../../../../../../ which is not nice and also not very secure as i think.
I tried to inhibit this matching with a lot of rules,but none works.
RewriteRule ^test//+$ http://mysite.com/test [R,NC,L]
-> should match whenever there is more than 1 slash at the end of the url, and redirect. But it doesnt work.
The rules in the top should not match more than 1 slash in the end in the first place, since its /?, meaning zero or ONE occurence... this also works fine with say letters, but not with the god damn slash. I also tested it in a regex tool and it matches correctly, so it must be Apache related.
I read something here or elsewhere that the server might be merging the slashes at some level... not sure about that.
Using Apache 2.2.9
Can anyone shed some light onto this? Thanks!