- mod_rewrite question
- Posted by Karl Groves on March 13th, 2006
Using this rule:
Options +FollowSymLinks
RewriteEngine on
RewriteRule article/(.*)/(.*)/$ /articles/article.php?$1=$2
Why does this work:
http://www.karlcore.com/article/id/26/
but this does not:
http://www.karlcore.com/article/id/26
--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com
Accessibility Discussion List: http://smallerurl.com/?id=6p764du
- Posted by Dylan Parry on March 13th, 2006
Pondering the eternal question of "Hobnobs or Rich Tea?", Karl Groves
finally proclaimed:
At a guess, I'd say that the "/" in the middle is causing the problem?
What happens when you escape it "\/"? ISTM that because you have the
middle slash, the regexp is assuming that the final slash is also a
literal character, so will only accept strings ending in a slash.
--
Dylan Parry
http://electricfreedom.org -- Where the Music Progressively Rocks!
- Posted by Karl Groves on March 13th, 2006
Dylan Parry <usenet@dylanparry.com> wrote in news:1r3xbc19ere4c
$.dlg@dylanparry.com:
Which "/" in the middle? lol
--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com
Accessibility Discussion List: http://smallerurl.com/?id=6p764du
- Posted by Dylan Parry on March 13th, 2006
Pondering the eternal question of "Hobnobs or Rich Tea?", Dylan Parry
finally proclaimed:
Actually, reading it again, it's the final slash... it shouldn't be
there! The final slash means that the string *must* end in a slash as
you don't have a "?" character et al to say that the slash is optional.
--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
- Posted by Dylan Parry on March 13th, 2006
Pondering the eternal question of "Hobnobs or Rich Tea?", Karl Groves
finally proclaimed:
Read my other reply
I realised that my brain had completely missed
the word "article" in that line, so was reading the regexp as being
marked /.../ with a beginning and ending slash :s
--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
- Posted by Karl Groves on March 13th, 2006
Dylan Parry <usenet@dylanparry.com> wrote in
news:1woucppevfc4.dlg@dylanparry.com:
If I take that one out completely, then for some reason the PHP engine
doesn't get the post for the $id variable
--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com
Accessibility Discussion List: http://smallerurl.com/?id=6p764du
- Posted by hug on March 13th, 2006
Karl Groves <karl@NOSPAMkarlcore.com> wrote:
That's why I do little with htaccess, it's so *easy* to screw
something up and never know about it.
--
http://www.ren-prod-inc.com/hug_soft...action=contact
- Posted by Dylan Parry on March 13th, 2006
Pondering the eternal question of "Hobnobs or Rich Tea?", Karl Groves
finally proclaimed:
Interesting. Here is one of the regexps I use for one of my sites:
RewriteEngine On
ReWriteRule ^artist/([A-Z0-9a-z_]+)$ /artist.php?artist_id=$1 [L]
From looking at that, maybe you should change the "*" to "+" as the
asterisk means that you can have zero-or-more matching characters, but
the plus means one-ore-more. ISTM that part of your problem is that when
you remove the trailing slash, the whole string matches the first part
of the regexp.
I would try rewriting yours as:
RewriteRule ^article/(.+)/(.+)/?$ /articles/article.php?$1=$2
The "/?" means that the slash is optional. As it is, just adding "/?"
would also match "article///" which is a bit odd
--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
- Posted by Karl Groves on March 13th, 2006
Dylan Parry <usenet@dylanparry.com> wrote in
news:lvhfx1h36q2u.dlg@dylanparry.com:
Nope. For some reason, that still confuses it into not recognizing the POST
of $id (or rather the value of it)
--
Karl Groves
http://karlcore.com
http://chevelle.karlcore.com
Accessibility Discussion List: http://smallerurl.com/?id=6p764du
- Posted by hug on March 13th, 2006
Karl Groves <karl@NOSPAMkarlcore.com> wrote:
It sure looks like magic to me. I assume that Toby or whoever will
supply the proper incantation forthwith. If you find there is no
answer that works (unlikely) let me know, I will try to help you via
PHP even though it is "hackish". <g>
--
http://www.ren-prod-inc.com/hug_soft...action=contact


