We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Problem

Blog Sitemap

Currently I have an htaccess directive that I'm using that is stripping the .php from the end of all files on my website. I'm struggling to get my blog sitemap to display properly and I believe this is the issue. Here is the blog Sitemap page. https://cgplumbing.com/blog/blogSitemap which isn't displaying proper xml. Here is an identically done blog Sitemap on my site that works like it is supposed to "https://www.coloradoseodesign.com/blog/blogSitemap.php" . Does anyone have any idea on if it is possible to get the sitemap to work properly? I'm not even sure if this is the problem, but I think it is.

Here is the htaccess directive which is stripping the php file extension

RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
Matt Holovach

Matt Holovach 0 points

  • 2 years ago
Simon Clay

Simon Clay 127 points

Hi Matt,

I notice that visiting https://cgplumbing.com/blog/blogSitemap.xml shows a sitemap for the 1 blog post. Is that just a static file for reference?

If it is a '.php redirect' issue, you might be able to get around it by making the Perch sitemap page have a .xml extension and tell your server to process .xml files as .php, as described here: https://docs.grabaperch.com/perch/getting-started/file-extensions/

As mentioned in the article, I've found that different servers prefer different methods, here are some that have worked for me...

# Used for LOCAL MAMP
AddType application/x-httpd-php .php .xml

# Used for 1&1 Cloud Server
AddHandler php-script .xml

# Used for HEART Hosting
AddHandler cgi-script .xml

Simon you are correct I created that file is manually created and I would prefer not to do that moving forward.

That is awesome I'm going to try that out and I will get back to you. I have not seen or used that before so I'm going to play with it


I'm going to mark you as the solution because you forced me to think about it differently. I found the solution which was to make it so the php was removed from every file except for 1. So my URL's are all clean except for blog/blogSitemap. I added the following line to my htaccess as the first rewrite rule. Thank you for taking the time and teaching me something today.

RewriteRule ^blog/blogSitemap\.php$ - [L]
Simon Clay

Simon Clay 127 points

Nice one Matt. And I learned something too, nice tip about adding the rewrite rule for just the one page. Thanks.

Oh, and the 404 page is... something else! I 'cracked' up.

Nice play on words Simon.

I was actually thinking about allowing that page to be indexed. Just because it made me laugh.