Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
510 views
in Technique[技术] by (71.8m points)

.htaccess - Replace special character in htaccess

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 ;)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...