Last active
February 21, 2021 21:17
-
-
Save k-holy/6632237 to your computer and use it in GitHub Desktop.
Dynamic RewriteBase for Apache (mod_rewrite, mod_setenvif)
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
RewriteEngine On | |
#---------------------------------------------------------- | |
# RewriteBase for develop | |
#---------------------------------------------------------- | |
# SetEnvIf | |
SetEnvIf Host ^develop.example.com$ REWRITE_BASE=/path/to/develop | |
# or RewriteCond | |
#RewriteCond %{HTTP_HOST} ^develop.example.com$ | |
#RewriteRule . - [E=REWRITE_BASE:/path/to/develop] | |
#---------------------------------------------------------- | |
# RewriteBase for staging | |
#---------------------------------------------------------- | |
# SetEnvIf | |
SetEnvIf Host ^staging.example.com$ REWRITE_BASE=/path/to/staging | |
# or RewriteCond | |
#RewriteCond %{HTTP_HOST} ^staging.example.com$ | |
#RewriteRule . - [E=REWRITE_BASE:/path/to/staging] | |
#---------------------------------------------------------- | |
# RewriteBase for production | |
#---------------------------------------------------------- | |
# SetEnvIf | |
SetEnvIf Host ^www.example.com$ REWRITE_BASE=/path/to/production | |
# or RewriteCond | |
#RewriteCond %{HTTP_HOST} ^www.example.com$ | |
#RewriteRule . - [E=REWRITE_BASE:/path/to/production] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !\.(ico|gif|jpe?g|png|css|js)$ [NC] | |
RewriteRule ^(.*)$ %{ENV:REWRITE_BASE}/index.php [QSA,NS,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment