developerdave Posted April 25, 2010 Share Posted April 25, 2010 Hey guys, I have a .htaccess that rewrites all urls to index.php for my cms but I'd like to add some exceptions like Sitemap.php and sitemap.xml I've pasted my current .htaccess below any help is greatly appreciated. RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/?Sitemap.php RewriteRule . /index.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/199670-htaccess-rule/ Share on other sites More sharing options...
cags Posted April 25, 2010 Share Posted April 25, 2010 The first two RewriteConds means that the URL will only be rewritten if the file/directory requested doesn't exist. I assume you only wish to add them as exceptions because they are actually files, but they should already be exceptions. Quote Link to comment https://forums.phpfreaks.com/topic/199670-htaccess-rule/#findComment-1047961 Share on other sites More sharing options...
developerdave Posted April 25, 2010 Author Share Posted April 25, 2010 Ahhh lol I'm no expert with .htaccess rules but that seemed to work thank you very much sir Quote Link to comment https://forums.phpfreaks.com/topic/199670-htaccess-rule/#findComment-1047965 Share on other sites More sharing options...
developerdave Posted April 25, 2010 Author Share Posted April 25, 2010 Hey guys sorry to unsolve this but I'd rather post it here than start a whole new topic. I'm trying to get sitemap.xml to mod_rewrite to sitemap.xml.php with the below rule RewriteRule ^sitemap\.(xml(\.gz)?)$ /sitemap.xml.php [L] So I add it and I keep getting a 500 Server Error. Below is the whole .htaccess file, anyone have any idea's? I have a basic grasp on the .htaccess malarky now but this is beyond me lol RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^sitemap\.(xml(\.gz)?)$ /sitemap.xml.php [L] RewriteRule . /index.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/199670-htaccess-rule/#findComment-1048021 Share on other sites More sharing options...
cags Posted April 25, 2010 Share Posted April 25, 2010 RewriteConds only apply to the RewriteRule that follows them directly so placing your new rule where you have will cause issues with your redirects. The new rule should instead be before the RewriteConds (if you place it at the end of the file, the script will be redirected with the first rule, which you don't want, catch all redirects should always be at the bottom of a .htaccess). Try this instead... RewriteEngine On RewriteBase / RewriteRule ^sitemap\.xml(\.gz)?$ sitemap.xml.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/199670-htaccess-rule/#findComment-1048027 Share on other sites More sharing options...
developerdave Posted April 25, 2010 Author Share Posted April 25, 2010 Cags my man, you are indeed. A legend that worked. I didn't think of that. Thanks man hopefully be the last time I need to post on here haha Quote Link to comment https://forums.phpfreaks.com/topic/199670-htaccess-rule/#findComment-1048029 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.