![]() |
.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 Going to investigate further, though I'm not sure what I'm going to do, as that htaccess looks perfect to me :gonk: [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:
|
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 |
Instead of this:
Code:
RewriteRule play/(.*)/ index.php?play=$1 Code:
RewriteRule play/(.*)/? index.php?play=$1 |
That makes it work for requests without the end slash, though breaks it when a slash is used ;_;
Quote:
Thanks for the help =D |
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. |
All times are GMT -5. The time now is 01:39 AM. |
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2025, vBulletin Solutions, Inc.