Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

http://www.mysite.com/link/go/emailadress@gmail.com

is interpreted like this :

http://www.mysite.com/process.php?email=emailadress@gmail.com

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

share|improve this question

1 Answer 1

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

share|improve this answer
    
i tried but not working –  pollux1er Jul 12 '12 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 '12 at 23:04
    
Ok, I read your explanation, but it is not working –  pollux1er Jul 12 '12 at 23:06
    
ok let me paste it : –  pollux1er Jul 12 '12 at 23:07
    
Options +FollowSymlinks RewriteEngine on RewriteRule ^/link/go/(.*)$ /process.php?email=$1 –  pollux1er Jul 12 '12 at 23:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.