6

I changed my forum from kunena to phpbb3. Problem is that my old forum (that is indexed in google) has special characters in urls. I want to keep my urls, so old link works with new forum - but only when special characters are replace with normal letters.

I need to use htaccess to convert characters on the fly.

for example

ą => a
ę => e
ś => s
ć => c

so in words letters will be replaced like this

pościelówka => poscielowka

Can someone help me with that? p.s. sorry for bad English ;)

user2757017
  • 97
  • 1
  • 1
  • 5

1 Answers1

6

Try adding this to the htaccess file in your document root:

RewriteEngine On

RewriteRule ^(.*)ą(.*)$ /$1a$2 [L,R=301]
RewriteRule ^(.*)ę(.*)$ /$1e$2 [L,R=301]
RewriteRule ^(.*)ś(.*)$ /$1s$2 [L,R=301]
RewriteRule ^(.*)ć(.*)$ /$1c$2 [L,R=301]
RewriteRule ^(.*)ó(.*)$ /$1o$2 [L,R=301]

etc.

This redirects a URL like:

http://yourdomain.com/pościelówka

and redirects the browser to:

http://yourdomain.com/poscielowka

as long as the /poscielowka URI actually exists.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • it doesn't work for me :( i tried url `.... coś.html` I'vegot 404 with that text `/coÅ›.html was not found on this server.` – user2757017 Sep 07 '13 at 17:22
  • It works :D I add some lines like: RewriteRule ^(.*)Å›(.*)$ /$1s$2 [L,R=301] but it works now. Thank You :D – user2757017 Sep 07 '13 at 17:49
  • @user2757017 Weird, that looks like some unicode encoding issue either with htaccess file or apache – Jon Lin Sep 07 '13 at 17:55
  • Yes it's some encoding problem. What is wierd different browser shows different characters. I add few lines to htaccess for every encoding, and it works like charm now. – user2757017 Sep 07 '13 at 18:03
  • To avoid permanent cache problems I edited flag as `[R=301,L,E=nocache:1]` followed by these lines: `Header always set Cache-Control "no-store, no-cache, must-revalidate" env=nocache` and `Header always set Expires "Thu, 01 Jan 1970 00:00:00 GMT" env=nocache` – quantme Nov 16 '15 at 22:53
  • what about replacing **%20** with **+**? `RewriteRule ^(.*)%20(.*)$ /$1+$2 [L,R=301]` is not working – Elyor Dec 29 '17 at 09:41
  • I've solved my problem with this: RewriteRule ^(.*?)/u003d(.*)$ /$1=$2 [L,R=301] thank you! – Brian Sanchez Feb 08 '19 at 23:00