简体   繁体   English

用mod_rewrite重写URL

[英]Rewriting URL with mod_rewrite

I have Wordpress plugin that provides page translation to users by placing the Google translate tool on their website. 我有Wordpress插件,可通过将Google翻译工具放在用户的网站上来为用户提供页面翻译。 I want to add url rewrite capability so that when language is changed, the url is re-written. 我想添加URL重写功能,以便在更改语言时重写URL。

I have PHP/HTML code that changes languages by using simple links with fire events, like this: 我有PHP / HTML代码,可以通过使用带有火灾事件的简单链接来更改语言,如下所示:

<a href="#" class="nturl en" onclick="doGoogleLanguageTranslator('en|en'); return false;" title="English"><span class="flag"><img class="flagimg flagselect colorbox-4242" src="http://wp-studio.net/wp-content/plugins/google-language-translator/images/flags24/unitedkingdom.png" height="16" width="16" alt="English"/></span>English</a>

How would I go about adding this url rewrite functionality, based on the way I have implemented this? 根据实现方式,我将如何添加此URL重写功能? Can I do this by adding stuff to .htaccess , or do I need to reconfigure things to get started on this? 我可以通过在.htaccess添加内容来做到这一点,还是需要重新配置内容才能开始使用它?

I am assuming all the logic to translate the page is done via javascript on the page itself. 我假设所有翻译页面的逻辑都是通过页面本身上的javascript完成的。 In that case, you only need an internal rewrite in .htaccess that translates /pages/language/ to /pages . 在这种情况下,您只需要在.htaccess中进行内部重写即可将/pages/language//pages In the url will still /pages/language/ be displayed. 网址中仍会显示/pages/language/

RewriteRule ^([^/]+)/(en|de|fr|qq)$ $1 [L]

See the documentation for more information. 请参阅文档以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM