1

My framework is entirely dependant on mod_rewrite to be enabled on a server for routing purposes. Within my .htaccess file I check if mod_rewrite.c is enabled and do my rewrite rules within it. However, should mod_rewrite not be turned on, my application essentially would stop working as I do not want to do the http://www.domain.com/index.php/... url setup to ensure all requests still filter through index.php.

Is there a failsafe for me to direct all requests to say a internal 500 or possibly some error page (if I can define it customly that would be great) if mod_rewrite is turned off?

anubhava
  • 761,203
  • 64
  • 569
  • 643
mauzilla
  • 3,574
  • 10
  • 50
  • 86
  • possible duplicate of [Pretty URLs without mod\_rewrite, without .htaccess](http://stackoverflow.com/questions/975262/pretty-urls-without-mod-rewrite-without-htaccess) – Brewal Jun 18 '14 at 10:28

1 Answers1

0

You can keep all your mod_rewrite rules in <IfModule mod_rewrite.c> block and exceptions in <IfModule !mod_rewrite.c> block:

# execute when mod_rewrite is turned on
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>

# execute when mod_rewrite is turned off
<IfModule !mod_rewrite.c>
    RedirectMatch ^(?!/error\.php).*$ /error.php
</IfModule>
anubhava
  • 761,203
  • 64
  • 569
  • 643