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

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

问题描述

我将论坛从 kunena 更改为 phpbb3.问题是我的旧论坛(在 google 中编入索引)在 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ówka => poscielowka

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天全站免登陆