3

I am trying to write a patter in such a way that this link :

http://www.mysite.com/link/go/[email protected]

is interpreted like this :

http://www.mysite.com/[email protected]

But i dont know how to write. I tryied this but it is not working. Need help please.

This what I wrote in my .htaccess file but not working :

Options +FollowSymlinks
RewriteEngine on 
RewriteRule    ^link/go/overview/([A-Za-z0-9-]+)$    /process.php?email=$1    [NC,L]

Thanks

1 Answer 1

5
RewriteRule link/go/(.*)$ process.php?email=$1

This seems to work. You should do the email validation in process.php, not in the .htaccess rule for the sake of readability (plus, you can at least have a nice error message on the page).

This works because anything after link/go/ will be matched (. matches any character, so .* means match any character as many times as it can, and (.*) means save this into $1 - The $ at the end means end of line, so it'll match all the way to the end).

What you tried won't work because [A-Za-z0-9-]+ will only match letters and numbers, no @ or ..

9
  • i tried but not working
    – pollux1er
    Jul 12, 2012 at 23:01
  • I've tested it and it works, so I'm standing by the answer - you might have a conflicting rule elsewhere. Can you paste your entire .htaccess into the question?
    – Jay
    Jul 12, 2012 at 23:04
  • Ok, I read your explanation, but it is not working
    – pollux1er
    Jul 12, 2012 at 23:06
  • ok let me paste it :
    – pollux1er
    Jul 12, 2012 at 23:07
  • Options +FollowSymlinks RewriteEngine on RewriteRule ^/link/go/(.*)$ /process.php?email=$1
    – pollux1er
    Jul 12, 2012 at 23:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .