htaccess的重定向目录名参数 [英] htaccess Redirect directory name to parameter

查看:283
本文介绍了htaccess的重定向目录名参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重定向这样的所有路径:

I would like to redirect all paths like this:

myurl.com/worldwide/en
myurl.com/worldwide/pt
myurl.com/worldwide/de

myurl.com/worldwide/index.php?lang=en
myurl.com/worldwide/index.php?lang=pt
myurl.com/worldwide/index.php?lang=de

只要是明确的路径后,一个充满活力的重定向 /世界范围

其实我非常希望保留原有的URL(如: myurl.com/worldwide/de ),但加载使用语言目录相同的PHP文件作为参数,但不知道这是可能的吗?

Actually ideally I would like to keep the original url (e.g. myurl.com/worldwide/de) but load the same php file with the language directory as a param but not sure if this is possible?

感谢

推荐答案

使用这种code

RewriteEngine On
RewriteBase /worldwide/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?lang=$1 [L,QSA]

请让我知道如果这可以帮助你。

Please let me know if this helps you

这篇关于htaccess的重定向目录名参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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