[英]mod_rewrite: insert index.php if URL contains X
I'm trying to use mod_rewrite to change: 我正在尝试使用mod_rewrite进行更改:
http://example.com/?wpdmact=process&did=m5d4FG3
to: 至:
http://example.com/index.php?wpdmact=process&did=m5d4FG3
I just want to insert index.php
. 我只想插入index.php
。
Here is the code I have tried, but that is not working: 这是我尝试过的代码,但是没有用:
RewriteCond %{QUERY_STRING} wpdmact=process&did=(.*)
RewriteRule (.*) /index.php?wpdmact=process&did=%1 [R=301,L]
I have successfully created the following similar redirect on this same site: 我已经在同一站点上成功创建了以下类似重定向:
RewriteCond %{QUERY_STRING} page_id=(.*)&preview=true
RewriteRule (.*) /index.php?page_id=%1 [R=301,L]
I have a Wordpress site that has a static index.html
in the root folder along with index.php
. 我有一个Wordpress网站,该网站的根文件夹中有一个index.html
以及index.php
。 This is to have a lighter, faster loading homepage. 这是一个更轻,更快的加载主页。 The only challenges this has created are the two I'm mentioning here. 这带来的唯一挑战是我在这里提到的两个挑战。 It breaks because in these instances the site redirects to index.html
, instead of index.php
. 之所以中断,是因为在这些情况下,该网站重定向到index.html
而不是index.php
。
I don't do a lot of work with mod_rewrite, so any help you can offer is greatly appreciated. 我对mod_rewrite的工作不多,因此,您能提供的任何帮助将不胜感激。
This should work: 这应该工作:
RewriteCond %{QUERY_STRING} wpdmact=process&did= [NC]
RewriteRule ^$ /index.php [R=301,L]
QUERY_STRING
is automatically carried over to new URL. QUERY_STRING
将自动结转到新的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.