[英]mod_rewrite rule to change parent folder
Some unchangeable hyperlinks on a website point to /folderA/index.php?id=somestuff
. 网站上一些/folderA/index.php?id=somestuff
更改的超链接指向/folderA/index.php?id=somestuff
。 I need to redirect the Request to /folderB/index.php?id=somestuff
instead. 我需要将请求重定向到/folderB/index.php?id=somestuff
。
I did some experimenting with this but I just can't get it to work, any help is appreciated. 我对此进行了一些试验,但是我无法使其正常工作,感谢您的帮助。
RewriteEngine on
RewriteRule /folderA/index\.php\?id=([\w-]+)$ /folderB/index.php?id=$1
Assuming that you are not planning on using different get request this should work: 假设您不打算使用其他get请求,则应该可以使用:
RewriteEngine on
RewriteRule /folderA/index\.php\?id=(.*?)$ /folderB/index.php?id=$1
Keep in mind that RewriteRule doesn't match query string and matches only REQUEST_URI without it. 请记住,RewriteRule与查询字符串不匹配,仅与没有它的REQUEST_URI匹配。 Use this code instead: 请改用以下代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+folderA/(index\.php\?id=[^&\s]+) [NC]
RewriteRule ^ /folderB/%1 [R=302,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.