重命名根目录(htaccess)中已翻译的html文件的url [英] Rename the url of the translated html files in the root (htaccess)

查看:83
本文介绍了重命名根目录(htaccess)中已翻译的html文件的url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Web应用程序,并尝试向网站添加两种语言。因此,我将制作以-gr结尾的相同文档。文件的一些示例如下所示:

I am building a web app and trying to add two languages to the website. So I will make the same documents ending in -gr. Some examples of the files look like this:

英语路径:


www.example.com/index.html

www.example.com/Blog.html

www.example.com/index.html
www.example.com/Blog.html

希腊语语言路径:


www.example.com/index-gr.html < br>
www.example.com/Blog-gr.html

www.example.com/index-gr.html
www.example.com/Blog-gr.html

是否可以将希腊文件重命名为某些内容类似于以下示例:

Is that possible to rename the greek files to something like the following example:

www.example.com/blog-gr.html /

应重命名为

www.example.com/blog/gr

例如:删除所有希腊文档的-gr.html并在末尾添加/ gr。
也仅对于索引文件而言,example.com/index-gr.html应该为example.com/gr
谢谢

eg: Remove the -gr.html of all the greek documents and add /gr at the end. Also only for index file, example.com/index-gr.html should be example.com/gr Thanks

推荐答案

尝试一下

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)/gr$ greek/$1 [NC,L]

编辑

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html/gr$ $1-gr.html [NC,L]

这篇关于重命名根目录(htaccess)中已翻译的html文件的url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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