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
?
-
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.– Sean O'BrienCommented May 12, 2015 at 21:48
Add a comment
|
2 Answers
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.
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.
-
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 -
-
Why? If I go to
http://domain.com/common/sitemap.xml
, I get to the template. However, if I go tohttp://domain.com/common/sitemap/
, I get nothing. Commented May 18, 2015 at 19:49