I've recently changed scripting on my website, and this has resulted in a few 404 errors as some very old queries are no longer being redirected correctly.
I've been trying to create a rewrite rule to fix this, as it requires modifying the query string.
This is an example of a broken URI:
/index.php?/page/index.html/_/news/this-is-a-page-r34
If I can rewrite the query string as so, the request will succeed:
/index.php?/article.html/_/news/this-is-a-page-r34
So, with this in mind I have tried various rewrite rules in my .htaccess
file, but have not been having any success. Amongst a few other variations, I have tried the following:
1st attempt
RewriteCond %{QUERY_STRING} ^(.*)page/index.html(.*)$
RewriteRule /index.php /index.php?%1article.html%2 [L]
2nd attempt
RewriteCond %{QUERY_STRING} ^/page/index.html/(.*)$
RewriteRule /index.php /index.php?/article.html/$1 [L]
3rd attempt
RewriteCond %{QUERY_STRING} ^/page/index.html(.*)$
RewriteRule . /index.php?/article.html$1 [L]
It does appear to be matching the RewriteCond
, so that's something, but the output never seems to get rewritten according to the RewriteRule
.
Can anybody see where I'm going wrong? I think I've got to the point where I've been looking at it for too long and have become code blind.