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, simon_w

Useless mod_rewrite rule in the default silverStripe .htaccess ?


Reply


1514 Views

Avatar
Myrdhin

Community Member, 67 Posts

10 November 2009 at 5:10am

Edited: 17/11/2009 1:25am

Hello,

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 [url=http://wiki.apache.org/httpd/RewriteRule]this page about Rewrite rules[/url] :

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.