Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 105037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:22:33+00:00 2026-05-11T01:22:33+00:00

I rewrite URLs to include the title of user generated travelblogs. I do this

  • 0

I rewrite URLs to include the title of user generated travelblogs.

I do this for both readability of URLs and SEO purposes.

  http://www.example.com/gallery/280-Gorges_du_Todra/ 

The first integer is the id, the rest is for us humans (but is irrelevant for requesting the resource).

Now people can write titles containing any UTF-8 character, but most are not allowed in the URL. My audience is generally English speaking, but since they travel, they like to include names like

  Aït Ben Haddou 

What is the proper way to translate this for displaying in an URL using PHP on linux.

So far I’ve seen several solutions:

  1. just strip all non allowed characters, replace spaces this has strange results:
    'Aït Ben Haddou' → /gallery/280-At_Ben_Haddou/
    Not really helpfull.

  2. just strip all non allowed characters, replace spaces, leave charcode (stackoverflow.com) most likely because of the ‘regex-hammer’ used
    this gives strange results: 'tést tést' → /questions/0000/t233st-t233st

  3. translate to ‘nearest equivalent’
    'Aït Ben Haddou' → /gallery/280-Ait_Ben_Haddou/
    But this goes wrong for german; for example ‘ü’ should be transliterated ‘ue’.

For me, as a Dutch person, the 3rd result ‘looks’ the best.
I’m quite sure however that (1) many people will have a different opinion and (2) it is just plain wrong in the german example.

Another problem with the 3rd option is: how to find all possible characters that can be converted to a 7bit equivalent?

So the question is:

  1. what, in your opinion, is the most desirable result. (within tech-limits)

  2. How to technically solve it. (reach the desired result) with PHP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:22:34+00:00Added an answer on May 11, 2026 at 1:22 am

    Ultimately, you’re going to have to give up on the idea of ‘correct’, for this problem. Translating the string, no matter how you do it, destroys accuracy in the name of compatibility and readability. All three options are equally compatible, but #1 and #2 suffer in terms of readability. So just run with it and go for whatever looks best — option #3.

    Yes, the translations are wrong for German, but unless you start requiring your users to specify what language their titles are in (and restricting them to only one), you’re not going to solve that problem without far more effort than it’s worth. (For example, running each word in the title through dictionaries for each known language and translating that word’s diacritics according to the rules of its language would work, but it’s excessive.)

    Alternatively, if German is a higher concern than other languages, make your translation always use the German version when one exists: ä→ae, ë→e, ï→i, ö→oe, ü→ue.

    Edit:

    Oh, and as for the actual method, I’d translate the special cases, if any, via str_replace, then use iconv for the rest:

    $text = str_replace(array('ä', 'ö', 'ü', 'ß'), array('ae', 'oe', 'ue', 'ss'), $text); $text = iconv('UTF-8', 'US-ASCII//TRANSLIT', $text); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using http://urlrewriter.net/ to rewrite urls at my website. For example, I'm rewriting: http://www.example.com/schedule.aspx?state=ca
What would be the best way to rewrite URLs like http://www.example.com/page to http://www.example.com/?pg=page ?
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to rewrite URLs as follows: www.example.com/module-name(/) => handler.php?module=module-name www.example.com/module-name/list/of/arguments(/) => handler.php?module=module-name&args=list/of/arguments (which
Ok, this is driving me nuts... I'm trying to rewrite my urls like this:
I use the below mod rewrite code for urls like: www.site.com/play/543 RewriteEngine On RewriteRule
I have to rewrite URLs which don't include specific words like 'contact', 'about', 'list'
I am using url rewrite in my website to rewrite my url from www.mydomain.com/user/profile?id=1
I have a dirty URL like this: http://www.netairspace.com/photos/photo.php?photo=3392 . I want to do something
I am looking to rewrite urls with multiple substrings. One substring is being requested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.