I recently switched my blog from wordpress to ghost. In order to keep the old wordpress urls working, I added some rewrite rules.
My wordpress site used the following url formats:
/blog/year/month/post-title
/blog/index.php/year/month/post-title
Ghost uses the following url format:
/post-title
Here’s my main rewrite rule. It works fine for the pattern without index.php, but with index.php, it redirects to /index/
.
<rule name="wordpress to ghost" stopProcessing="true">
<match url="^blog/(index.php/)?d+/d+/([w-]+)/?" />
<action type="Redirect" url="{R:2}" />
</rule>
How can I fix this rule to correctly redirect urls with index.php?
I’ve tested this with my own installed instance of Ghost on Azure, but I’m not getting the redirect you are.
{R:2}
correctly returns the second grouping (slug name).However, I do notice that you are not escaping your forward slashes. Try the following: