htaccess语言转换 [英] htaccess language conversion
问题描述
我做了一个阿拉伯语和英语网站。所有文件都存储在根目录中。我没有为阿拉伯语或英语创建任何单独的文件夹,也没有为阿拉伯语或英语创建任何文件。我只是用阿拉伯语或英语制作了两种语言的数组。如果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屋!