.htaccessmod-rewritesitemapsymlinkmultiviews

Stop htaccess from redirecting certain file types?


My htaccess works exactly as I want it to except it is also redirecting my sitemap files. Does anyone know what can be changed or added to keep it from effect any .xml files but continue to work the same for anything else?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/review/$1 [R=301,L]

Options -MultiViews +FollowSymlinks -Indexes

RewriteEngine on
RewriteRule ^([a-zA-Z0-9\.\-]+)$ review.php?site=$1 [L,QSA]

Basically write now it shows the contents of mysite.com/review/review.php?site=$1 when you go to mysite.com/review/$1 and I want it to continue to work like that, just not for .xml files.

Basically if someone goes to mysite.com/review/sitemap.xml it should show the actual sitemap, not the contents of mysite.com/review/review.php?site=sitemap.xml

Any help would be greatly appreciated. Thanks!


Solution

  • Right before:

    RewriteRule ^([a-zA-Z0-9\.\-]+)$ review.php?site=$1 [L,QSA]
    

    add:

    RewriteCond %{REQUEST_URI} !\.xml$ [NC]
    

    The condition only matches if the URI doesn't end with a .xml and only gets applied to the rule that routes to review.php.