Jump to content

URL Segments and Umlauts throw 404


EvanFreyer
 Share

Recommended Posts

Hey there,

I have a problem with URL Segments and Umlauts in it. I want to grab the a segment of the url and use it as a parameter to find a something in Processwire. The problem is, that if I input an umlaut into the url, processwire immediately throws a 404 error page and I am not able to transform my inputs.

Is there a way to get around that problem?

Cheers,

Evan

Link to comment
Share on other sites

Some code or screen would make shure that you've get the right answer.

- Where you put umlauts in which input (frontend form ->Code example?)

- How do you use the url segment code example

- are you using the name attribute of the $page and not the title?

...regards mr-fan

Link to comment
Share on other sites

@EvanFreyer, open your .htaccess file and look for this line:

# OPTIONAL: Send URLs with non name-format characters to 404 page

This is the first step at enabling non-ascii URLs, though I'm not entirely sure if it's the only one you need to change.

  • Like 4
Link to comment
Share on other sites

@teppo: Thanks for the info! I removed the redirection and now I can access the page. However, it seems to strip umlauts from the url. I haven't found that option yet.

@mr-fan: Code examples are not relevant right now. I added a template and allowed URL Segmentation. I don't have any rules set up at all, so it just accepts it. Until now, an Umlaut leads to the default 404 page and the code of the template was not executed at all.

With teppo's changes to the htaccess (I should have known that, damn... thanks again ;)), the page is at least called. Now I have to search, where processwire or the htaccess strips my Umlauts.

Link to comment
Share on other sites

One hacky solution would be parsing the URL manually from $_SERVER['REQUEST_URI']. It's nowhere near as clean and simple as checking $input->urlSegment1, you'll have to route these requests through your home page each and every time, and it won't be a valid solution for all use cases.. so perhaps not the best thing to do after all :)

Somehow I was under the impression that URL segments wouldn't be as "strict" as actual URLs, no idea where I got such idea.

Link to comment
Share on other sites

I thought, URL Segments are not part of the page-name restrictions as well since I only saw them as an alternative to GET-parameters. I changed the programming, so that it will search for an ID rather than the title of something, so that still works, but the URL is not as pretty.

But just for the sake of discussing things: If I integrate a tagging system for news and if I like to have some kind of overview of all news by a certain tag, I was under the impression, that I can use URL Segments to indicate which tag I was searching for. Since all Tags would be unique, the name alone could be my identifier. Do I have to use GET-Parameters, if I wanted to do it the "PW-way", since something like news/bytag/ÄÖÜ is not supported?

I hope, I made myself clear, I can be a little bit confusing ;).

Link to comment
Share on other sites

Here you've the statement from Ryan about this: https://processwire.com/talk/topic/580-encrypted-urlsegment/?p=4652

@Evan

Most likely you're tags will be created as pages, therefore they'll already have a pageName. Just use this as urlSegment and you're good to go. If you want to use the new options fieldtype you could instead use the value|Label syntax.

E.g: A german tag "Männer" would could get the name "maenner" (Page) or be defined as option like this: "1=maenner|Männer". Both would work for this url: example.com/tags/maenner/

  • Like 2
Link to comment
Share on other sites

I ran into some problems while developing, perhaps someone could help me?

I am trying to use the pageName as the identifier right now and everything works, but $page->name always returns the english page name and not the localized. I fixed that with using $page->localName($user->language). However, my selector does not seem to work that way. It seems as if it does not find the local value. I am using $page->find("name=".$sanitizer->selectorValue($localName)). The English version works flawless.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...