Re: Re: Regex help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Sep 9, 2008, at 12:18 PM, Jochem Maas wrote:

Jason Pruim schreef:
On Sep 9, 2008, at 5:02 PM, Nathan Rixham wrote:
Jason Pruim wrote:
On Sep 9, 2008, at 4:38 PM, Nathan Rixham wrote:
Jason Pruim wrote:
Hey everyone,
Not completely specific to php but I know you guys know regex's better then I do! :) I am attempting to match purl.schreurprinting.com/jasonpruim112 to purl.schreurprinting.com/p.php?purl=jasonpruim112
Here are my current matching patterns:
RewriteRule /(.*) "/volumes/raider/webserver/ documents/dev/schreurprinting.com/p.php?purl=$
#               RewriteRule /(*.) "/purl.schreurprinting.com/$1"
# RewriteRule /(mail.php?purl=*) "/ purl.schreurprinting.com/mail.php?purl=$1" Yes I am doing this for apache's mod_rewrite, but my question is much more specific to regex's at this point :) Any ideas where I am going wrong? it seems like it should be fairly simple to do, but I don't know regex's at all :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx

RewriteRule ^jasonpruim112$ /p.php?purl=jasonpruim112 [L]
Just tried it, and it pops up with a 404... I'll keep looking.
One other thing that I should probably add is the fact that the ^jasonpruim112$ could have hundreds of counterparts.... ^bobsmith112$ ^jerrybob112$ etc... etc...
Thanks for looking though!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx

here's a typical rule; probably best to modify what works and go from there :)

RewriteRule ^directory/(.*)$ /newdirectory/$1 [L]

the other alternative is to let php handle it..
this is basicaly if request isn't a file or a directory route to a php handler [my prefered way]:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /notfound_handler.php [L]

RewriteRule . /notfound_handler.php [L,QSA]

the QSA tells apache to to automatically append any query string, saves the hassle of having to deal with it in the regexp (assuming you might need it)

also beware that external redirects will cause POSTs to become GETs so that
the script/code in question never recieves the POST.

Interesting... that may explain a problem I am having with some other local links in that directory...



Interesting idea... I hadn't thought about that... Then I could just use a regex in php and grab everything after the domain name and pass it to my database to search and find the appropriate info to pull out...

your probably wanting the info in $_SERVER['REQUEST_URI'] ... which is
the complete uri before it was rewritten.

That's actually what I started using, then I just explode that to get my query string to use in the database lookup.



also check this func out, will probably spare you the regexp completely:

http://php.net/manual/en/function.parse-url.php

Ohhh... That sounds promising... I'll have to take a look at it later.


I'll have to do some searching :)

always ;-)

The problem with the internet is there is so much out there... Trying to weed the crap from the food can be a long digestive process which ends up with MORE crap coming out... This list... It's like pepto bismo for my programming :P


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@xxxxxxxxxx





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux