Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RewriteRule and the number sign “#”

I'm trying to make a friendly URL through RewriteRule but it keeps ignoring # as part of the variable value.
The line on .htaccess is as simple as this

RewriteRule ^key/(.+)/$ index.php?key=$1  

and the requested URL is

http://www.example.com/key/c%23/  

but I'm only getting c as get variable and not c%23.

What exactly am I doing wrong?

like image 352
GRaecuS Avatar asked May 20 '11 19:05

GRaecuS


1 Answers

Finally after some digging, I managed to pull this off.

It just needs the B flag on RewriteRule to escape non-alphanumeric characters such as #

RewriteRule ^key/(.+)/$ index.php?key=$1 [B]
like image 63
GRaecuS Avatar answered Oct 16 '22 02:10

GRaecuS