Jump to content

.htaccess rule


developerdave

Recommended Posts

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.