below is my current .htaccess file. I would like to add another condition/rule where if a request for sitemap.xml is made, sitemap.php is served instead. Please help : )
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L,QSA]
</IfModule>
You could do it explicitly:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap.xml$ sitemap.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L,QSA]
</IfModule>
You'll likely run into problems doing this though... You should create exclusions for spiders so they still receive the sitemap.xml
RewriteRule ^sitemap.xml$ public/sitemap.php [L]
make sure your php file loads as xml, using the code bellow
header('Content-Type: text/xml');