Created
May 5, 2014 21:31
-
-
Save simonewebdesign/2b1090d9756855ed45ef to your computer and use it in GitHub Desktop.
.htaccess redirect all requests to a subfolder
This file contains hidden or 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
| # /.htaccess | |
| RewriteEngine on | |
| RewriteBase / | |
| RewriteCond %{REQUEST_URI} !^/public/ | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule ^(.*)$ /public/$1 [L] | |
| #---------------------------------------------------- | |
| # /public/.htaccess | |
| # Put off automatic trailing slashes in directories | |
| DirectorySlash Off | |
| # Manually put back trailing slashes in directories | |
| RewriteBase / | |
| RewriteCond %{REQUEST_URI} ^((/?[A-Z][A-Za-z0-9]*)+[^/])$ | |
| RewriteRule ^((/?[A-Z][A-Za-z0-9]*)+[^/])$ index.php?page=$1 [L] | |
| RewriteCond %{REQUEST_FILENAME} -d | |
| RewriteRule ^([a-z0-9][A-Za-z0-9/]*[^/])$ $1/ [R,L] | |
| # Redirect all requests | |
| RewriteRule ^(.*)$ $1 [NC] | |
| # Handle errors | |
| ErrorDocument 404 404frompublic.html | |
| ErrorDocument 500 500frompublic.foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment