radmen / lassy

Lazy static site generator for Laravel 4
MIT License
11 stars 0 forks source link

Better redirection rules for apache #4

Open dolfje opened 10 years ago

dolfje commented 10 years ago

Because the .htaccess rules on the frontpage doesn't always work, I've created my own rules. The .htaccess file should be put into the public folder and works on every path. So it doesn't has to be top domain. (I'm also trying to get a proper nginx configuration, but aren't there yet)

RewriteEngine On

# Split the request uri into path till this directory and path after it

RewriteRule  ^(.*)$ - [NC,E=ARG:$1]

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]

# Now handle the static pages

RewriteCond %{DOCUMENT_ROOT}%{ENV:BASE}_static/index.html -f
RewriteRule ^index.php$ _static/index.html

RewriteCond %{DOCUMENT_ROOT}%{ENV:BASE}_static/%{ENV:ARG} -f
RewriteCond %{REQUEST_FILENAME} !_static/
RewriteRule ^(.*)$ _static/%{ENV:ARG}

RewriteCond %{DOCUMENT_ROOT}%{ENV:BASE}_static/%{ENV:ARG}/index.html -f
RewriteCond %{REQUEST_FILENAME} !_static/
RewriteRule ^(.*)$ _static/%{ENV:ARG}

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !_static/
RewriteRule ^ index.php [END]
radmen commented 10 years ago

Thank you! I'll check this later.

Could you create from this MR updating README.md ?