mod_rewrite: insert index.php if URL contains X

I’m trying to use mod_rewrite to change:

http://example.com/?wpdmact=process&did=m5d4FG3

to:

Read More
http://example.com/index.php?wpdmact=process&did=m5d4FG3

I just want to insert 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. 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.

I don’t do a lot of work with mod_rewrite, so any help you can offer is greatly appreciated.

Related posts

Leave a Reply

1 comment

  1. 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.