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/14 03:16] – [Save the current directory as an environment variable] jquah | htaccess_recipes [2022/02/23 21:41] – Added not about not applicable to nginx-served peteyboy | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== .htaccess recipes ====== | ====== .htaccess recipes ====== | ||
+ | |||
+ | :!: Note: .htaccess only works at SDF on pages served by Apache, which at the time of this writing (2022/ | ||
+ | |||
=== Introduction === | === Introduction === | ||
Line 32: | Line 35: | ||
===== Save the current directory as an environment variable ===== | ===== Save the current directory as an environment variable ===== | ||
- | If you made your website accessible via tilde-style URLs (running '' | + | You might already be aware that the options in an htaccess file will affect all the files in subdirectories of the htaccess file location, unless overridden by htaccess files deeper into the path. But did you ever wish you could dynamically infer the location of your base htaccess file, for substitution into later directives? It turns out that Perl regexes (used in Apache' |
+ | |||
+ | If you made your website accessible via tilde-style URLs (running '' | ||
< | < | ||
Line 49: | Line 54: | ||
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' | 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' | ||
+ | |||
+ | Because these RewriteRules impose additional processing demands on the server for each request, hacks like these should be a last resort. If the other workarounds mentioned in [[custom_error_pages_for_your_site|custom error pages for your site]] address your use case, they should be implemented instead. | ||
===== Add (or force) MIME-type ===== | ===== Add (or force) MIME-type ===== | ||
htaccess_recipes.txt · Last modified: 2022/08/01 20:35 by peteyboy