1

I need help with my .htaccess file.

The links are: http://example.com/se-stockholm.html

But when I select a city that contains ÅÄÖ will the url become:

http://example.com/se-rebro.html and not se-örebro.html

My .htacess file looks like this today:

RewriteRule ^ ([^ / \.] +) - ([^ / \.] +). Html? $ Search.php? Co = $ 1 & location = $ 2

How can I add so it prints with ÅÄÖ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Paoh
  • 11
  • 1
  • 2
    Where exactly does the URL become `se-rebro.html`? Is this in the (HTML) output of some other page? Or does it get changed by a redirect or something? – Jonathan Jan 18 '14 at 15:33
  • possible duplicate of [Should I use accented characters in URLs?](http://stackoverflow.com/questions/1386262/should-i-use-accented-characters-in-urls) – Sverri M. Olsen Jan 18 '14 at 15:37
  • This needs clarification to be answerable. – Pekka Jan 18 '14 at 20:52

1 Answers1

1

Add to you .htaccess or in httpd.conf the following configuration line (directive):

AddDefaultCharset utf-8

Apache HTTP Server Manual:

This directive specifies a default value for the media type charset parameter (the name of a character encoding) to be added to a response if and only if the response's content-type is either text/plain or text/html. This should override any charset specified in the body of the response via a META element, though the exact behavior is often dependent on the user's client configuration. A setting of AddDefaultCharset Off disables this functionality. AddDefaultCharset On enables a default charset of iso-8859-1. Any other value is assumed to be the charset to be used, which should be one of the IANA registered charset values for use in MIME media types.

Don't dorget to restart your httpd server in case of editing httpd.conf.

EDIT 1:

Looking at your rewriterules, I would recommend you trying the following insted:

RewriteRule ^(.*)-(.*)/(.*).html?$ search.php?co=$1&location=$2&keyword=$3 
RewriteRule ^(.*)/(.*).html?$ search.php?co=$1&keyword=$2 
RewriteRule ^(.*)-(.*).html?$ search.php?co=$1&location=$2
Ilia Ross
  • 13,086
  • 11
  • 53
  • 88
  • Thans for your answer. I add AddDefaultCharset utf-8 in my .htaccess and in httpd.conf, but it is the same problem :/ – Paoh Jan 18 '14 at 15:45
  • Please make sure that there is only one `AddDefaultCharset` directive! – Ilia Ross Jan 18 '14 at 15:56
  • @Paoh Does your `RewriteRule` works with other requests, that doesn't contain special characters? – Ilia Ross Jan 18 '14 at 16:09
  • @Paoh What is the output of `curl -I yourdomain.com` when running it on command prompt? – Ilia Ross Jan 18 '14 at 16:20
  • @Rostovtsev It's works with out a problem, only problem is ÅÅÖ. This is the full .htacess `AddDefaultCharset utf-8` `RewriteEngine on` `RewriteRule ^([^/\.]+)-([^/\.]+)/([^/\.]+).html?$ search.php?co=$1&location=$2&keyword=$3` `RewriteRule ^([^/\.]+)/([^/\.]+).html?$ search.php?co=$1&keyword=$2` `RewriteRule ^([^/\.]+)-([^/\.]+).html?$ search.php?co=$1&location=$2` `ErrorDocument 404 /404.php` – Paoh Jan 18 '14 at 16:39
  • what did you mean with curl -I yourdomain.com, hehe :o) – Paoh Jan 18 '14 at 16:48
  • Can you run from SSH `curl -I yourdomain.com`? – Ilia Ross Jan 18 '14 at 16:58
  • @Paoh Try updated *rewriterules* and let me know if it works for you!? – Ilia Ross Jan 18 '14 at 17:14
  • This is unlikely to work because UTF-8 characters have no business being in a URL. They will probably be URL encoded. See [Unicode characters in URLs](http://stackoverflow.com/q/2742852) – Pekka Jan 18 '14 at 17:20
  • @Pekka웃 Then what would be the solution? Congratulations on `7,000` answers - Amazing!! :) – Ilia Ross Jan 18 '14 at 17:29
  • Thanks, had't noticed! :) I don't understand the OP's question well enough to understand what goes wrong in the first place. @Paoh you didn't answer Jonathan's question in the comment above. Where exactly are things going wrong? – Pekka Jan 18 '14 at 17:43