« first day (776 days earlier)      last day (3016 days later) » 

2:28 AM
@zx81 What's up
 
@hwnd preparing first vacation in years… about to load the truck with all kinds of trash for the tip. You having a fun day?
 
Ahh nice, where you vacating too? Yea it's been a decent enjoyable day.
 
friend's place in the bush, in Oz
 
Nice, I'll be pretty busy in the next month. I'll be packing up and leaving VA to move to TX for work.
 
Harrr... Good for you. Hope you grow us some nice lilts and drawl. Sorry, being called away to fold a giant piece of netting. Catch you another time bro!
 
2:40 AM
@zx81 Sounds good, take care man!
@nhahtdh What's new?
 
@hwnd Scroll a bit up. Well, or you can look at my profile ;)
Planning to write something about the insane length-check of look-behind in Java, but need to find time
 
Been studying the API?
 
@hwnd I have been studying the code since last year, but only now and then
Anyway, I have got the structure down since last year, so it's easy for me to narrow down the error to certain function
 
Nice, I'll be looking for a post about it in the near future.
 
Don't star it, though.
I need to sync it to my current code
 
 
5 hours later…
7:51 AM
Hey guys!
A mate and I are struggling with .htaccess and rewriterules
basically we need the user to be redirected when it the URL contains .png
and when it does NOT have .png, it has to redirect somewhere else
so: "website/image/test.png" should redirect to --> file1.php
and "website/image/test" should redirect to --> file2.php
 
30
Q: Reference: mod_rewrite, URL rewriting and "pretty links" explained

deceze"Pretty links" is an often requested topic, but it is rarely fully explained. mod_rewrite is one way to make "pretty links", but it's complex and its syntax is very terse, hard to grok and the documentation assumes a certain level of proficiency in HTTP. Can someone explain in simple terms how "p...

You'll probably need something along the lines:
RewriteEngine On
RewriteRule ^website/image/.*\.png$ file1.php
 
But, it does need the file name.
so I would need to capture it in a group, I know that and use $1
 
Then catch the filename
 
the first part works.
like, match if it contains .png
but we can not make it work to NOT match .png
We've been looking into negative look ahead/behind but it does not do the job
 
RewriteEngine On
RewriteRule ^website/image/([^/]+)\.png$ file1.php?png=$1
 
7:59 AM
because the file name can be a-zA-Z0-9
so it does also match png
 
RewriteEngine On
RewriteRule ^website/image/([^/]+)\.png$ file1.php?png=$1 [NC,L]
RewriteRule ^(?!.*\.png$)website/image/([^/]+)$ file2.php?file=$1 [NC,L]
@CasNouwens ^ quick and dirty. Try it out...
 
Alright, holdon. I'll report back with the result
 
Ah, I need to write a "betoog". I'm so bad at this stuff -_-
 
@HamZa It does not work. It also matches when it ends with .png
It's actually in the root directory
so website/image/ would be /
xxx.com/abc
xxx.com/abc.png
and
 
@CasNouwens So RewriteRule ^([^/]+)\.png$ file1.php?png=$1 [NC,L] doesn't work?
 
8:13 AM
It does but as soon as I add in the second one (the not one) it uses that one even if it ends with .png
 
@CasNouwens have you added the NC,L flags?
^ just to be sure :)
 
yup
 
Weird...
 
@HamZa Here's what we got
RewriteEngine on
RewriteRule ^([^/]+)\.png$ loader.php?x=$1 [NC,L]
RewriteRule ^(?!.*\.png$)([^/]+)$ notpng.php?x=$1 [NC,L]
 
@CasNouwens weird...
 
8:20 AM
yup
 
Try something really simple in the second line:
RewriteRule ^foobar$ notpng.php
 
that works
 
Ok... This probably means there's something wrong with our expression
 
Tried to escape the / in the (^[/]), but that didn't help either
regex101 bitched about the / being there
but that didn't fix it eiter
either*
 
@CasNouwens to use regex101, just change the delimiter (click on it)
@CasNouwens Do the files actually exists. For example does foobar.png exist?
 
8:30 AM
not in that folder
if blabla.png is requested, increase viewcount in DB and return the file
otherwise, redirect to the view that contains blabla.png (in an IMG tag)
 
Does this work RewriteRule ^(?!.*\.png$).+ notpng.php?x=$0 [NC,L]?
^ typo $0
 
doesn't work
 
lol
This is why I hate .htaccess ...
 
I never used it much, but i'm not liking it so far :p
...
RewriteEngine on
RewriteRule ^(.*)\.png$ loader.php?x=$1 [NC,END]
RewriteRule ^(.*)$ notpng.php?x=$1 [NC,END]
that fixed it..
 
lolwut....
Needs to google about END...
 
8:39 AM
END is like L, but it terminates then and there
 
(This is why I never answer .htaccess question - since I don't know how it treats the URL string)
 
@nhahtdh haha true. It depends on the environment...
Also L worked for me in almost all cases...
 
Weird because L:
> The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. This corresponds to the last command in Perl, or the break command in C. Use this flag to indicate that the current rule should be applied immediately without considering further rules.
 
notable here: <b>In most contexts</b>
 
8:43 AM
yup ^^
 
going for a smoke
 
Oh, I see the problem now...
It was looping...
So when we used: RewriteRule ^([^/]+)\.png$ loader.php?x=$1 [NC,L]
foobar.png got rewriten to
loader.php?x=foobar
Then it re-executed the .htaccess and the second rule met since there's no .png at the end!
TIL END is useful ....
Therefore, we could also use a rewrite condition...
but that's another story...
I also get why my queries worked in the past. I used:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@CasNouwens Smoking at such a young age (SMH)
 
9:05 AM
@HamZa I know, but I'm quitting on may 8th
 
@CasNouwens what an exact date... Care to explain or is it too personal?
 
Eh, kinda personal, but my brother is going away for a while on may 8 and on may 8 I quit smoking as show of support (and to better my own health ofc :p)
 
Nice. I hope you succeed in your goals :)
 
9:30 AM
Thanks, mate
 
Welcome :)
 

« first day (776 days earlier)      last day (3016 days later) »