1

I have created a template that outputs my XML Sitemap dynamically (via Channel entry loop). Currently, it's in commmon/sitemap.xml. How do I tell EE that whenever http://somedomain.com/sitemap.xml is accessed, it should output commmon/sitemap.xml?

1
  • While trying to solve the same problem, I did some research and found it was unnecessary, at least with respect to Google support. Not only is it okay to put a sitemap in a subdomain, you can put it at an entirely different URL. Commented May 12, 2015 at 21:48

2 Answers 2

1

You need to ensure your index.php rewrite happens after the rewrite to the template group.

RewriteCond $1 ^(sitemap_index\.xml|sitemap\.xml|product-feed\.xml) [NC]
RewriteRule ^(.*)$ /common/$1 [L]
...
RewriteCond $1 !^(images|themes|robots\.txt|index\.php|admin\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

For certain builds with strict 404's and using Structure, I've had to create a page in Structure to keep it happy, but otherwise it should rewrite fine.

0

I've used resource router by Sanchez. I expect you could do something similar with EE template routes too.

Alternatively, you could look at modifying your htaccess rules.

3
  • I'm not sure how resource router can help as it seems to require the template group name. What's the template group name of root? I've tried this rewrite rule: RewriteRule ^/?sitemap\.xml$ /common/sitemap.xml [L], but it doesn't work because I think it expects "/common/sitemap.xml" to be a "real" file. Commented May 12, 2015 at 2:31
  • Remove the 2nd .xml part from your htacess. Commented May 12, 2015 at 2:38
  • Why? If I go to http://domain.com/common/sitemap.xml, I get to the template. However, if I go to http://domain.com/common/sitemap/, I get nothing. Commented May 18, 2015 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.