Determining if something is there, or not there.

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Determining if something is there, or not there.

Post by someberry »

I'm not sure how plausible this is, hopefully it can be done but I do not hold my breath. I can't test this out right now since I am at work!

I have a site, say http://www.example.org/page/param.

In some cases the 'page' part will not always be there, but I still need to get both the 'page' and 'param' part. Would something like this work:?

Code: Select all

RewriteRule ^([\w]+)?/([\w]+)         index.php?page=$1&param=$2
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Determining if something is there, or not there.

Post by JAB Creations »

Code: Select all

<?php if (file_exists("install.php")) {die("boot to the head");?>
Also I think you can avoid using regex (which creates unnecessary load on the server) because it seems you're looking for a static position...

Try looking at some of the various options here...
http://us2.php.net/reserved.variables.server

I also recommend checking this out...
http://us3.php.net/strpos

See that page's "See Also" part (just above the comments). This seems like something you can almost definitely avoid having to use regex with. :D
Post Reply