Jump to content

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.