3

I am using the following ModRewrite to make my urls look cleaner:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?key=$1

It allows use of letters and numbers just fine, but it produces a 400 error when i try to use %, which I require to use unicode characters for # / ', etc. Any reason behind this? Thanks.

Rob W
  • 341,306
  • 83
  • 791
  • 678
Joshua Davis
  • 325
  • 7
  • 15
  • What error messages do you see in your logs? – Rob W Oct 30 '11 at 16:02
  • `[Sun Oct 30 16:17:15 2011] [error] [client ::1] File does not exist: /Applications/MAMP/htdocs/search/$3` – Joshua Davis Oct 30 '11 at 16:17
  • 1
    Hehe.. What input (url) did you offer, what result (url) did you get, and what's the relevant error message? – Rob W Oct 30 '11 at 16:22
  • look at this , it's usefull :http://stackoverflow.com/questions/459667/how-to-encode-special-characters-using-mod-rewrite-apache – undone Oct 31 '11 at 01:39

1 Answers1

3

you should use B flag in your rewrite rule. take a look at apache manual .

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-#$%^&]+)/?$ index.php?key=$1 [B]

Edit: mod_rewrite uses unescaped characters, so if you want to use unicode characters, use them in rewrite rule and save .htaccess file in unicode!

undone
  • 7,857
  • 4
  • 44
  • 69