简体   繁体   中英

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:

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM