Apache Mod_Rewrite 正则表达式帮助
我正在尝试修改 URL 和变量,但不确定是否遇到语法错误或只是使用了错误的表达式。
我试图改变这个:
http://www.mydomain.com/trainings/12345
进入这个:
http://www.mydomain.com/remote.php?page=abcde&var=12345
remote.php?page=abcde 是静态的,永远不会改变。因此只需传递该变量并去掉 URL 中的 /trainings 即可。 12345将会改变。
我尝试了以下方法,但没有成功:
RewriteCond %{QUERY_STRING} /trainings/(.*)
RewriteRule remote.php?page=abcde remote.php?page=abcde&var=%1 [QSA,L]
我还尝试了上述方法的一些变体,但没有成功。
我很确定我使用了错误的语法。非常感谢任何帮助!
I'm trying to modify a URL and variable, and I'm not sure if I'm running into syntax errors or just using the wrong expressions.
I'm trying to turn this:
http://www.mydomain.com/trainings/12345
into this:
http://www.mydomain.com/remote.php?page=abcde&var=12345
The remote.php?page=abcde is static and will never change. So just need to pass that variable and strip out the /trainings in the URL. The 12345 will change.
I've tried the following with no luck:
RewriteCond %{QUERY_STRING} /trainings/(.*)
RewriteRule remote.php?page=abcde remote.php?page=abcde&var=%1 [QSA,L]
I've also tried some variations of the above with no success.
I'm pretty sure I'm using the wrong syntax. Any help is much appreciated!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该有效
This should work