BandonRandon Posted July 6, 2009 Share Posted July 6, 2009 Hello, I'm trying a new method to prevent spam bots which is to use a link like "mailto.php?u=user&d=example&s=com" the idea is that this gets passed to the php script "mailto.php" which has the following code <?php // pull values from query string and // redirect to a mailto link header("Location: mailto:$_GET[u]@$_GET[d].$_GET[s]"); ?> This worked fine but I thought the url looked to messy so i was able to clean it up by writing the following rewrite rule RewriteRule ^email/[a-z0-9_]+/[a-z0-9_]+/[a-z0-9_]+$ core/includes/mailto.php?u=$1&d=$2&s=$3 [L,NC] This also works when the url is something like "email/user/exampe/com" The problem is that i'm not sure how to get the pieces to the mailto.php so they can be called into the e-mail client right now my email client will open with " @ . " which means that the script is working but because there is nothing in the $_GET variables it's returning null. Any help on this would be great. Brooke Quote Link to comment https://forums.phpfreaks.com/topic/164905-solved-parse-url-and-clean-urls/ Share on other sites More sharing options...
Adam Posted July 6, 2009 Share Posted July 6, 2009 Try this: header("Location: mailto:" . $_GET['u'] . "@" . $_GET['d'] . "." . $_GET['s']); Quote Link to comment https://forums.phpfreaks.com/topic/164905-solved-parse-url-and-clean-urls/#findComment-869608 Share on other sites More sharing options...
BandonRandon Posted July 7, 2009 Author Share Posted July 7, 2009 Thanks for your reply MrAdam, however the issue wasn't with the PHP it was with the regex. You're php makes more sense and looks a bit cleaner though so I'm using it instead. The problem was I didn't put parenthisis around my regex to allow them to be backreferences the corrected rewrite rule for anyone wanting to know is this: RewriteRule ^email/([a-z0-9_]+)/([a-z0-9_]+)/([a-z0-9_]+)$ core/includes/mailto.php?u=$1&d=$2&s=$3 [L,NC] Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/164905-solved-parse-url-and-clean-urls/#findComment-870223 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.