I’m experiencing an issue with URL encoding and unexpected redirects on an Apache server.
- My
.htaccess
usesRewriteRule
to implement human-readable URLs in Korean. - All project files are saved in UTF-8.
- Friendly URLs include UTF-8–encoded Korean characters (e.g.
/products/과자/치토스
which is /snacks/Cheetos in English) - The actual server-side pages are English-only (e.g.
/product_view.php
)
Problem:
When I request a UTF-8–encoded URL, Apache responds with a 301 redirect to the same URL — but percent-encoded in EUC-KR, resulting in a unreadable address bar. For example:
Request: /products/과자/치토스 Response: 301 → /products/%B0%FA%C0%DA%C4%A1%C5%E4%BD%BA
address bar: mydomain/products/%B0%FA%C0%DA%C4%A1%C5%E4%BD%B
which is unreadable.
The encoding shift seems to be happening during the redirect, even though the source files, HTML headers, and URL are all UTF-8. This causes character corruption and confusing behavior for users.
What I’ve verified:
- All
.php
,.js
, and.html
files are UTF-8 without BOM - Apache’s default charset is not explicitly set — I tried
AddDefaultCharset UTF-8
in.htaccess
but the redirect issue persists RewriteRule
itself does not include[R=301]
, but the redirect still occurs. Here is my RewriteRule code
RewriteRule ^products/([^/]+)/([^/]+) /products/product_view.php?product=$2 [L]
Question:
- Why is Apache sending a 301 with EUC-KR encoding?
- How can I ensure that UTF-8 URLs are preserved and served correctly without charset corruption or unwanted redirect?
Thanks in advance for any guidance!