1

How To make Validation URL contain foreign language Like Arabic symbols with Laravel Like this https://www.dott.com/news/1061/صاحب-السمو-يدشن-مصفاة-لفان-2

  • for me it worked very well -even for arabic- without any special needs. if you've any errors, exceptions, etc... please add it. – M.Elwan Mar 12 '17 at 12:18

1 Answers1

1

Just to point out:

If you don't believe me then do a "View source in this question to verify that the URL is actually:

<a href="https://www.dott.com/news/1061/%D8%B5%D8%A7%D8%AD%D8%A8-%D8%A7%D9%84%D8%B3%D9%85%D9%88-%D9%8A%D8%AF%D8%B4%D9%86-%D9%85%D8%B5%D9%81%D8%A7%D8%A9-%D9%84%D9%81%D8%A7%D9%86-2" rel="nofollow noreferrer">https://www.dott.com/news/1061/صاحب-السمو-يدشن-مصفاة-لفان-2</a>

You therefore need to do:

$url = urlencode("https://www.dott.com/news/1061/صاحب-السمو-يدشن-مصفاة-لفان-2");

However, if a browser gets a URL encoded string they are usually happy to translate the URL encoded symbols to characters and show them in the address bar.

As a reminder valid URL characters are:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=`.

Check What characters are valid in a URL? or https://www.rfc-editor.org/rfc/rfc3986 for more details.

Community
  • 1
  • 1
apokryfos
  • 38,771
  • 9
  • 70
  • 114
  • Awesome, it works like a charm, but only changed the last section of the URL which output the post permalink as follow: ``. Thank you so much. – Jodyshop Aug 16 '20 at 17:31