htaccess的正则表达式目录变量 [英] htaccess regex directory to variable

查看:153
本文介绍了htaccess的正则表达式目录变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做301重定向从目录中的变量某些URL。

I need to make a 301 redirect for certain URLs from directory to variable.

例如:

    http://domain.com/es/stackoverflow --> http://domain.com/stackoverflow?lang=es
    http://domain.com/he/stackoverflow --> http://domain.com/stackoverflow?lang=he

因为它是现在我有一个目录结构为每一种语言,它的制作单独的URL相同的页面,它只是切换语言。

As it is now I have a "directory structure" for each language and it's making seperate URLs for the same page, it just switches the language.

我只想补充语言标识符底。

I just want to add the language identifier at the end.

的事情是不是每个页面有这些语言标识符的TLD后/

The thing is not every page had those language identifiers after the tld/

有什么想法?

感谢您的时间。

推荐答案

您可以试试:

RedirectMatch 301 ^/([a-z]{2})/(.*)$ /$2?lang=$1

这篇关于htaccess的正则表达式目录变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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