htaccess_recipes
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
htaccess_recipes [2022/02/13 20:59] – changed to internal DokuWiki link jquah | htaccess_recipes [2022/02/14 03:11] – [Save the current directory as an environment variable] jquah | ||
---|---|---|---|
Line 30: | Line 30: | ||
'' | '' | ||
+ | ===== Save the current directory as an environment variable ===== | ||
+ | |||
+ | If you made your website accessible via tilde-style URLs (running '' | ||
+ | |||
+ | < | ||
+ | RewriteEngine on | ||
+ | RewriteBase "/" | ||
+ | RewriteCond $0# | ||
+ | RewriteRule ^.*$ - [E=CWD:%2] | ||
+ | |||
+ | RewriteCond %{HTTP_HOST} ^(www\.)? | ||
+ | RewriteCond %{REQUEST_FILENAME} !-f | ||
+ | RewriteCond %{REQUEST_FILENAME} !-d | ||
+ | RewriteRule ^.*$ %{ENV: | ||
+ | </ | ||
+ | |||
+ | The # symbol serves as an arbitrary delimiter, ensuring that the second parenthesized group captures the working directory that's known to the server at the time of processing. Whether the working directory is an absolute pathname on the filesystem or an alias that will later be expanded by mod_userdir, | ||
+ | |||
+ | This example can be extended to perform different redirections depending on which virtual host handled the transaction (just create a new stanza with a different condition on %{HTTP_HOST}). In this way you can give your visitors the same experience whether they' | ||
===== Add (or force) MIME-type ===== | ===== Add (or force) MIME-type ===== | ||
htaccess_recipes.txt · Last modified: 2024/09/04 23:36 by hc9