: Encoded 301 redirects don't work, only english one does I have a .htaccess file that in its end I created some 301 redirects. For example: Redirect 301 /site-building-from-home / Redirect 301
I have a .htaccess file that in its end I created some 301 redirects. For example:
Redirect 301 /site-building-from-home /
Redirect 301 /%D7%9E%D7%96%D7%99%D7%9F-%D7%AA%D7%9B%D7%A0%D7%99%D7%9D /
For some reason all redirects with an English alias (say, site-building-from-home) works but all these with encoded aliases (Hebrew-to-machine-language) don't.
Do we have an Apache-directives/PCRE expert that can explain this phenomena ?
(Note: I used / instead a domain-name+TLD for flexibility considerations).
More posts by @Bryan171
1 Comments
Sorted by latest first Latest Oldest Best
As it states in the Apache docs for a mod-alias Redirect:
The old URL-path is a case-sensitive (%-decoded) path ...
So, assuming /%D7%9E%D7%96%D7%99%D7%9F-%D7%AA%D7%9B%D7%A0%D7%99%D7%9D is the actual request as sent from the client, then you will need to match against the literal, percent-decoded (aka URL-decoded), text in the Redirect directive. From your example this would be:
Redirect /מזין-תכנים /
(Make sure your .htaccess file is UTF-8 encoded.)
If you want to match the percent-encoded URL, as sent from the client, then you will need to use mod_rewrite and match against THE_REQUEST server variable (which is not percent-decoded). For example:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /%D7%9E%D7%96%D7%99%D7%9F-%D7%AA%D7%9B%D7%A0%D7%99%D7%9D HTTP/
RewriteRule ^ / [R=301,L]
You will need to enable the rewrite engine earlier in your code if not already ie. RewriteEngine On.
However, if you change to using mod_rewrite redirects then it is strongly recommended to change your mod_alias Redirects to use mod_rewrite as well in order to avoid unexpected conflicts.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.