Forum

Rewrite rules for Wordpress Yoast Sitemap

Nick L.
18 February 2015, 23:57
Hi everyone,

I'm not having much luck setting up the correct rewrite rules for using the Yoast Sitemap plugin in Wordpress.

Everything is pointing to http://mysite.com/index.php/sitemap_index.xml instead of just http://mysite.com/sitemap_index.xml

I'm used to Nginx and these nginx rewrite rules work for me:
rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

How can I get this working with Hiawatha? Any help would be greatly appreciated!

Thanks so much,
Nick

Hiawatha version: Latest Hiawatha!
Operating System: Debian Jessie
Hugo Leisink
19 February 2015, 09:20
The fact that you have an index.php within the path of your URL makes me wonder if "EnablePathInfo = yes" would be sufficient. Otherwise, try this one:
VirtualHost {
...
UseToolkit = yoast
}

UrlToolkit {
ToolkitID = yoast
Match ^/([a-z]+)?-?sitemap\.xsl$ Rewrite /index.php?xsl=$1
Match ^/sitemap_index\.xml$ Rewrite /index.php?sitemap=1
Match ^/([^/]+?)-sitemap([0-9]+)?\.xml$ Rewrite /index.php?sitemap=$1&sitemap_n=$2
}
Nick L.
20 February 2015, 15:24
Thanks so much Hugo! I will try those rewrite rules out tonight to see if they work...I'm not sure what EnablePathInfo is but I will look it up . I'm loving Hiawatha but I'm just having a hard time with the rewrites ( I have never been good with rewrites and most of my nginx ones come from googling them, I just couldn't find much info on Hiawatha rewrites), once I get Yoast working then I just have to get W3TC or Supercache working and I will be all set =).
Nick L.
20 February 2015, 20:03
It worked Hugo!!! Thanks so much! The only thing is...when using the provided Wordpress toolkit config on Hiawatha's website, it puts index.php into every url so http://mywebsite.com/category/ becomes http://mywebsite.com/index.php/category . I had to change the permalinks to a custom type and take out the index.php but after I did that everything worked correctly and the toolkit rewrites you provided for Yoast worked too!

Now I just have to get W3TC Cache plugin working correctly I'll try playing around with it and seeing if I can get the rewrites working.
This topic has been closed.