替换htaccess的特殊字符 [英] Replace special character in htaccess

查看:551
本文介绍了替换htaccess的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变了我的论坛,从使用Kunena到PHPBB3。问题是,我的老论坛(即收录在谷歌)在URL的特殊字符。我想保持我的网址,所以旧的链接可以与新的论坛 - 但只有当特殊字符替换正常的字母

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.

我需要使用htaccess的字符转换的飞行。

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

例如

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

所以在单词的字母将被替换像这样

so in words letters will be replaced like this

PO 取值 CIEL 0 的WKA => PO 取值 CIEL 0 WKA

pościelówka => poscielowka

有人可以帮助我吗? 附:对不起不好英语;)

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

推荐答案

尝试在你的文档根目录下添加这对htaccess文件:

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]

等。

此重定向的URL,如:

This redirects a URL like:

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

和浏览器重定向到:

http://yourdomain.com/poscielowka

只要 / poscielowka URI确实存在。

as long as the /poscielowka URI actually exists.

这篇关于替换htaccess的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆