获取URL的最后一部分作为GET参数 [英] Get last part of an URL as GET parameter

查看:205
本文介绍了获取URL的最后一部分作为GET参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的网址:

http://example.com/foo/bar/de/
http://example.com/foo/bar/en/

我必须使用哪些重写规则在最后一个文件夹"(http://example.com/foo/bar/)之前加载URL,并将此文件夹"作为GET参数(例如lang=de)

Which rewrite rules do i have to use to load the URL before the last "folder" (http://example.com/foo/bar/) and get this "folder" as GET parameter (e.g. lang=de)

推荐答案

我知道了:

RewriteEngine on
RewriteRule ^language/(.*)$ index.php?l=$1

现在,我可以打开类似 http://example.com/foo/bar/language的URL /de/,但浏览器会加载 http://example.com/foo/bar/index.php?l = de

Now i can open URLs like http://example.com/foo/bar/language/de/ but the browser loads http://example.com/foo/bar/index.php?l=de

这篇关于获取URL的最后一部分作为GET参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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