php - 在 2 个路径之间重写查询字符串
问题描述
我是 .htaccess 的新手,所以希望有人可以帮助我。
我正在尝试重定向这些:
clan.php/tagID=clanstag
clanRatings.php/tagID=clanstag
对此:
/clan/clanstag
/clan/clanstag/ratings
到目前为止,我已经正确重定向了 clan.php,但我无法让 clanRatings.php 正确重定向。它一直认为 Clans 标签是 clantag/ratings。
这是我现在使用的代码:
# Rewrite clan.php
RewriteEngine On
#url redirection from old url to the new one
#redirect /clan.php?tagID=TAG to /clan/TAG
RewriteCond %{THE_REQUEST} /clan.php\?tagID=([^\s]+) [NC]
RewriteRule ^.+$ /clan/%1? [L,R]
#url rewiring from new url to the old one
# rewrite /clan/TAG to /clan.php?tagID=TAG
RewriteRule ^clan/(.*)$ clan.php?tagID=$1 [L]
和
# Rewrite clanRatings.php
RewriteEngine On
#url redirection from old url to the new one
#redirect /clanRatings.php?tagID=TAG to /clan/TAG/ratings
RewriteCond %{THE_REQUEST} /clanRatings.php\?tagID=([^\s]+) [NC]
RewriteRule ^.+$ /clan/%1?/ratings [L,R]
#url rewiring from new url to the old one
# rewrite /clan/TAG/ratings to /clanRatings.php?tagID=TAG
RewriteRule ^clan/(.*)$/ratings clanRatings.php?tagID=$1 [L]
在此先感谢您的帮助!
解决方案
推荐阅读
- c - C 编程通过引用指针函数调用以删除结构的成员
- c++ - 如何使另一个线程拥有的对象的画布无效?
- gradle - Gradle依赖解析的逻辑是什么
- javascript - 如何在 pug 文件中的脚本上使用渲染的第二个参数“locals”?
- python - 无法更改图表上的刻度频率
- reactjs - React Native Change Functional State inside State 到 Class State inside State
- json - 将数据从 StructA 传递到 VCA,然后从 VCA 传递到 VCB
- python - 如何禁用 FutureWarning:将 (type, 1) 或 '1type' 作为 type 的同义词传递是不推荐使用的警告?
- 64-bit - 如何使用 try-catch 捕获浮点错误?
- r - 对组数据进行分类