Reputation: 33
Iam Using URL Re Write in .htacces File. Below is The Exact code. its Working Fine. But While i pass Unicode characters in arguments [ie: mypage.php?id=2&name=தமிழ்]. it shows some code like '%25E0%25AE%25A8%25E0%25AE%2' and Result is Page Not Found 404. Can anybody Solve this issue?
RewriteEngine on
RewriteCond %{THE_REQUEST} /mypage\.php\?id=([^\s&]+)&name=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9+]+)/?$ mypage.php?id=$1&name=$2 [L,QSA]
Upvotes: 2
Views: 1069
Reputation: 143886
When the URI is used to match against a rewrite rule's regex pattern, it is first decoded, so those %
and hex values get turned into unicode. Your regex pattern [A-Za-z0-9-]+
won't match unicode. Try changing your second rule so that it matches anything that isn't /
instead:
RewriteEngine on
RewriteCond %{THE_REQUEST} /mypage\.php\?id=([^\s&]+)&name=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ mypage.php?id=$1&name=$2 [L,QSA]
Upvotes: 3