Skip to content

Better redirection rules for apache #4

@dolfje

Description

@dolfje

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions