Gamingforce Interactive Forums
85239 35211

Go Back   Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Network > Help Desk
Register FAQ GFWiki Community Donate Arcade ChocoJournal Calendar

Notices

Welcome to the Exploding Garrmondo Weiner Interactive Swiss Army Penis.
GFF is a community of gaming and music enthusiasts. We have a team of dedicated moderators, constant member-organized activities, and plenty of custom features, including our unique journal system. If this is your first visit, be sure to check out the FAQ or our GFWiki. You will have to register before you can post. Membership is completely free (and gets rid of the pesky advertisement unit underneath this message).


.htaccess aids
Reply
 
Thread Tools
Roph
ヽ(ºДº)ノ


Member 63

Level 25.06

Mar 2006


Reply With Quote
Old May 29, 2007, 11:09 AM Local time: May 29, 2007, 05:09 PM #1 of 5
.htaccess aids

So I'm rewriting

http://slyph.org/music/kylelandry/vi...asie_Impromptu to http://slyph.org/music/kylelandry/vi...sie_Impromptu/ , though I can't get it to work if the htaccess'd url is missing an end slash.

Here's the contents of my .htaccess,

Code:
Options +FollowSymLinks
RewriteEngine on
ReWriteBase /music/kylelandry/video/
RewriteRule play/(.*)/ index.php?play=$1
RewriteRule play/(.*) index.php?play=$1
I'd have thought the last line would have made requests without the end slash (http://slyph.org/music/kylelandry/vi...asie_Impromptu for example) work fine, though it just comes back with the error I made my script spit out when the video request doesn't match an array of all the videos there.

Going to investigate further, though I'm not sure what I'm going to do, as that htaccess looks perfect to me

[edit] Ok, I updated my script so that if it is a bad request then it'll echo what the request was, and it looks like the / in my variables is fucking with it. When requesting one without the end /:

Quote:
Invalid Video selected!
(testing, request was "Classical")
Uhh,

Jam it back in, in the dark.

Last edited by Roph; May 29, 2007 at 11:15 AM.
Snowknight
may carry parasites


Member 165

Level 22.05

Mar 2006


Reply With Quote
Old May 29, 2007, 02:37 PM #2 of 5
If I'm remembering correctly, the existence of URLs without a trailing slash requires that you do something like this for the second RewriteRule:

Code:
RewriteRule play/(.*)/(.*) index.php?play=$1$2
I'm not making any guarantees, though; I've never really used mod_rewrite much. If all else fails, you could make your PHP add a trailing slash when one does not exist.

There's nowhere I can't reach.
THE POWER OF WATER
listen here you little shit


Member 45

Level 48.64

Mar 2006


Reply With Quote
Old May 29, 2007, 04:15 PM Local time: May 29, 2007, 02:15 PM #3 of 5
Instead of this:

Code:
RewriteRule play/(.*)/ index.php?play=$1
RewriteRule play/(.*) index.php?play=$1
Do this:

Code:
RewriteRule play/(.*)/? index.php?play=$1
A question mark means to match 0 or 1 of the previous character or group, which in this case is the slash.

This thing is sticky, and I don't like it. I don't appreciate it.
Undertale (PC, 2015)
Roph
ヽ(ºДº)ノ


Member 63

Level 25.06

Mar 2006


Reply With Quote
Old May 29, 2007, 06:33 PM Local time: May 30, 2007, 12:33 AM #4 of 5
That makes it work for requests without the end slash, though breaks it when a slash is used ;_;

Quote:
Invalid Video selected!
(testing, request was "Classical/Chopin_-_Fantasie_Impromptu/")
Hmm, I think I'll just stick with this though and remove the end slash if present with PHP.

Thanks for the help =D

I am a dolphin, do you want me on your body?
Fleshy Fun-Bridge
Hi there!


Member 907

Level 22.05

Mar 2006


Reply With Quote
Old May 29, 2007, 09:08 PM #5 of 5
I think your real problem is that the regex pattern .* is greedy, in that it will try to match the longest string of text possible. Given the text:

/play/Classical/Chopin_-_Fantasie_Impromptu/

/play/(.*)/? will always include the trailing slash in the match because it still satisfies the pattern and is longer than a match without the slash. The solution is to use a non-greedy qualifier such as /play/(.*?)/? instead. That will try to match as little text as possible while satisfying the pattern.

I was speaking idiomatically.
---
Reply


Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Network > Help Desk > .htaccess aids

Forum Jump


All times are GMT -5. The time now is 02:27 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.