Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

Useless mod_rewrite rule in the default silverStripe .htaccess ?

Go to End



Community Member, 70 Posts

10 November 2009 at 5:10am

Edited: 17/11/2009 1:25am


In my .htaccess file, i have mod_rewrite rules :

  RewriteEngine On
  RewriteBase /

  RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$) 

  RewriteCond %{REQUEST_URI} ^(.*)$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]

It's OK, these default rules works. But, i've read in this page about Rewrite rules :

  A wrong assumption is that the conditions are processed before the pattern of the RewriteRule. But this is wrong. The processing order is as follows: 

    1 - The Pattern of the RewriteRule is checked first.

So, i'm wondering : is RewriteCond %{REQUEST_URI} ^(.*)$ usefull ? It seems to be almost the same as .* pattern of the RewriteRule.

Perhaps Could we write :

  RewriteEngine On
  RewriteBase /Tests_CMS/SilverStripe

  RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$) 

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ sapphire/main.php?url=%1&%{QUERY_STRING} [L]

thanks for your explanations.