Created
September 2, 2012 14:49
-
-
Save satooshi/3599884 to your computer and use it in GitHub Desktop.
mod_rewrite for front controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
# skip existent files | |
RewriteCond %{REQUEST_FILENAME} -f | |
RewriteRule index.php - [QSA,L,C] | |
RewriteRule .* - [QSA,L] | |
# deny access php files | |
RewriteCond %{REQUEST_URI} ^.*\.php$ | |
RewriteRule ^.*\.php$ - [R=404,L] | |
# asset | |
RewriteCond %{REQUEST_URI} ^asset/*$ | |
RewriteRule ^asset/*$ - [QSA,L] | |
# redirect root access (/) to index.php | |
RewriteCond %{REQUEST_URI} ^/$ | |
RewriteRule ^$ index.php [QSA,L] | |
# redirect 404 for non existent files | |
RewriteCond %{REQUEST_URI} ^(.*)\..*$ | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)\..*$ - [R=404,L] | |
# no, so we redirect to our front web controller | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ index.php [QSA,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment