Hello folks! Short question here, I'm having a problem with .htaccess redirect function. ==== RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC] RewriteRule ^ %1 [R,NC] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\index.html [NC] RewriteRule ^ %1 [R,NC] ## ## Internal Redirect RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^ %{REQUEST_URI}.html Code (markup): ==== It works well, cutting the .html and the index.html from the url in the browser, but when a special character like a acute sign à or another ç, ã, it redirects to the 3 code symbol character: The folder structure/file is: /public_ftp/reidadedetizacaorj/orçamentobão.html ACTUAL BEHAVIOR: http://reidadedetizacaorj.com/or%C3%A7amentob%C3%A3o EXPECTED BEHAVIOR: http://reidadedetizacaorj.com/orçamentobão Because of this, host gator shows a 404 page because obviously because or%25C3%25A7amentob%25C3%25A3o is not a file in the server. Can you guys help me with the needed modifications on the .htaccess file?
Try this: RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC] RewriteRule ^ %1 [R,NC,NE] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\index.html [NC] RewriteRule ^ %1 [R,NC,NE] ## ## Internal Redirect RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^ %{REQUEST_URI}.html Code (markup):
Understanding RewriteRule flags: https://httpd.apache.org/docs/current/rewrite/flags.html NE is "noescape" which means that special characters aren't translated to their hexcode equivalent.
Like @PoPSiCLe said, the tag will stop converting the special character, and the 404 error would be solved.