htaccess语言转换 [英] htaccess language conversion

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

问题描述

我做了一个阿拉伯语和英语网站。所有文件都存储在根目录中。我没有为阿拉伯语或英语创建任何单独的文件夹,也没有为阿拉伯语或英语创建任何文件。我只是用阿拉伯语或英语制作了两种语言的数组。如果url说阿拉伯语,则来自arrayarabic的数据将与英语相同。

I made a website for arabic and english. All the files are stored in the root directory. I didn't made any separate folder for arabic or english nor any file for arabic or english. I just made a two language array for arabic or english. If url says arabic then data from arrayarabic will fetch and same case of english.

我要转换的内容
我当前的网址是

What I am requesting to convert My current url is

http://www.example.com/viewjob.php?job_id=11031

I想要转换为
http://www.example.com/ar/viewjob.php?job_id=11031 ,但没有用于ar的单独文件夹。

I want to convert if to http://www.example.com/ar/viewjob.php?job_id=11031 but there is no separate folder for ar.

请让我知道...谢谢。

Please let me know... thanks.

推荐答案

您可以使用mod_rewrite轻松完成此操作。当网址以 ar或 en开头时,您要获取其余的网址,并在内部重写为该网址的其余部分,并在其余查询字符串后附加一个参数:

You can accomplish this quite easily with mod_rewrite. When an url starts with either "ar" or "en", you want to take the rest of the url, and internally rewrite to the rest of the url and append a parameter to the rest of the query string:

RewriteEngine on

RewriteRule ^(en|ar)/(.*)$ $2?lang=$1 [QSA,L]

请参见文档

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

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