htaccess 301 redirect with encoded hebrew URLs

Deadly 提交于 2019-12-11 10:24:59

问题


I am currently working on a site in Hebrew, a large portion of links in this site have changed and i am now setting up the redirect rules through .htaccess; for some reason the redirect rules are not working. The old website was a static html website and this one a wordpress site.

The basic redirect syntax i am using is.

Redirect 301 /oldurl.html http://samedomain.co.il/newurl/

This works fine for all links with normal url encoding for the english version of the site; this even works when the redirect is to a page which its url encoded as such:

Redirect 301 /oldurl.html http://samedomain.co.il/%D7%A4%D7%A8%D7%96%D7%A0%D7%98%D7%A6%D7%99%D7%94-%D7%91%D7%90%D7%A0%D7%92%D7%9C%D7%99%D7%AA/

But does not work when the first part is also URL encoded as such:

Redirect 301 /%D7%A7%D7%95%D7%A8%D7%A1%D7%99%D7%9D-%D7%95%D7%A1%D7%93%D7%A0%D7%90%D7%95%D7%AA.htm http://samedomain.co.il/%D7%A4%D7%A8%D7%96%D7%A0%D7%98%D7%A6%D7%99%D7%94-%D7%91%D7%90%D7%A0%D7%92%D7%9C%D7%99%D7%AA/

I have tried several things, such as:

  1. Removing the forward slash.
  2. Encoding the slash to %47.

I am running out of ideas, any help would be appreciated.


回答1:


You need to use the decoded pattern, not the encoded one. The URI's get decoded before mod_alias/mod_rewrite get applied.

Redirect 301 /קורסים-וסדנאות.htm http://samedomain.co.il/%D7%A4%D7%A8%D7%96%D7%A0%D7%98%D7%A6%D7%99%D7%94-%D7%91%D7%90%D7%A0%D7%92%D7%9C%D7%99%D7%AA/


来源:https://stackoverflow.com/questions/17023869/htaccess-301-redirect-with-encoded-hebrew-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!