Jump to content

[SOLVED] parse url and clean urls


BandonRandon

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/164905-solved-parse-url-and-clean-urls/
Share on other sites

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.