From 8d57549d7e0611d1e0052aab56dfec8252101e93 Mon Sep 17 00:00:00 2001 From: Remington Steed Date: Wed, 21 Jan 2015 14:14:00 -0500 Subject: [PATCH] LP#1413621 Docs: Minor changes to Apache Rewrite Tricks This commit moves this doc file from TechRef into the official docs area, adds it to the root.txt file, and adds line breaks for easier viewing and editing of the file. Signed-off-by: Remington Steed --- .../apache_rewrite_tricks.txt} | 39 ++++++++++++++++------ docs/root.txt | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-) rename docs/{TechRef/Apache/rewrite_tricks.txt => admin/apache_rewrite_tricks.txt} (71%) diff --git a/docs/TechRef/Apache/rewrite_tricks.txt b/docs/admin/apache_rewrite_tricks.txt similarity index 71% rename from docs/TechRef/Apache/rewrite_tricks.txt rename to docs/admin/apache_rewrite_tricks.txt index 28ed236dca..2b96797f47 100644 --- a/docs/TechRef/Apache/rewrite_tricks.txt +++ b/docs/admin/apache_rewrite_tricks.txt @@ -1,10 +1,14 @@ Apache Rewrite Tricks --------------------- -It is possible to use Apache's Rewrite Module features to perform a number of useful tricks that can make people's lives much easier. +It is possible to use Apache's Rewrite Module features to perform a number of +useful tricks that can make people's lives much easier. Short URLs ~~~~~~~~~~ -Making short URLs for common destinations can simplify making printed media as well as shortening or simplifying what people need to type. These are also easy to add and require minimal maintenance, and generally can be implemented with a single line addition to your eg_vhost.conf file. +Making short URLs for common destinations can simplify making printed media as +well as shortening or simplifying what people need to type. These are also easy +to add and require minimal maintenance, and generally can be implemented with a +single line addition to your eg_vhost.conf file. [source,conf] ---- @@ -17,18 +21,27 @@ RewriteRule ^/search/isbn/(.*) /eg/opac/results?_special=1&qtype=identifier|isbn Domain Based Content with RewriteMaps ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -One creative use of Rewrite features is domain-based configuration in a single eg_vhost.conf file. Regardless of how many VirtualHost blocks use the configuration you don't need to duplicate things for minor changes, and can in fact use wildcard VirtualHost blocks to serve multiple subdomains. +One creative use of Rewrite features is domain-based configuration in a single +eg_vhost.conf file. Regardless of how many VirtualHost blocks use the +configuration you don't need to duplicate things for minor changes, and can in +fact use wildcard VirtualHost blocks to serve multiple subdomains. -For the wildcard blocks you will want to use a ServerAlias directive, and for SSL VirtualHost blocks ensure you have a wildcard SSL certificate. +For the wildcard blocks you will want to use a ServerAlias directive, and for +SSL VirtualHost blocks ensure you have a wildcard SSL certificate. [source,conf] ---- ServerAlias *.example.com ---- -For actually changing things based on the domain, or subdomain, you can use RewriteMaps. Each RewriteMap is generally a lookup table of some kind. In the following examples we will generally use text files, though database lookups and external programs are also possible. +For actually changing things based on the domain, or subdomain, you can use +RewriteMaps. Each RewriteMap is generally a lookup table of some kind. In the +following examples we will generally use text files, though database lookups +and external programs are also possible. -Note that in the examples below we generally store things in Environment Variables. From within Template Toolkit templates you can access environment variables with the ENV object. +Note that in the examples below we generally store things in Environment +Variables. From within Template Toolkit templates you can access environment +variables with the ENV object. .Template Toolkit ENV example, link library name/url if set [source,html] @@ -36,13 +49,15 @@ Note that in the examples below we generally store things in Environment Variabl [% IF ENV.eglibname && ENV.egliburl %][% ENV.eglibname %][% END %] ---- -The first lookup to do is a domain to identifier, allowing us to re-use identifiers for multiple domains. In addition we can also supply a default identifier, for when the domain isn't present in the lookup table. +The first lookup to do is a domain to identifier, allowing us to re-use +identifiers for multiple domains. In addition we can also supply a default +identifier, for when the domain isn't present in the lookup table. .Apache Config [source,conf] ---- # This internal map allows us to lowercase our hostname, removing case issues in our lookup table -# If you preferr uppercase you can use "uppercase int:toupper" instead. +# If you prefer uppercase you can use "uppercase int:toupper" instead. RewriteMap lowercase int:tolower # This provides a hostname lookup RewriteMap eglibid txt:/openils/conf/libid.txt @@ -63,7 +78,8 @@ branch2.example.com BRANCH2 branch3.example.com BRANCH3 ---- -Once we have identifiers we can look other information up, when appropriate. For example, say we want to look up library names and URLs: +Once we have identifiers we can look up other information, when appropriate. +For example, say we want to look up library names and URLs: .Apache Config [source,conf] @@ -115,12 +131,13 @@ BRANCH3 6 CONS 1 ---- -Going further, you could also replace files to be downloaded, such as images or stylesheets, on the fly: +Going further, you could also replace files to be downloaded, such as images or +stylesheets, on the fly: .Apache Config [source,conf] ---- -# A file exists based on eglibid and the requested file +# Check if a file exists based on eglibid and the requested file name # Say, BRANCH1/opac/images/main_logo.png RewriteCond %{DOCUMENT_ROOT}/%{ENV:eglibid}%{REQUEST_URI} -f # Serve up the eglibid version of the file instead diff --git a/docs/root.txt b/docs/root.txt index b65180b534..1becdc5eeb 100644 --- a/docs/root.txt +++ b/docs/root.txt @@ -157,6 +157,8 @@ include::admin/phonelist.txt[] include::admin/sip_server.txt[] +include::admin/apache_rewrite_tricks.txt[] + Using the Staff Client ====================== -- 2.11.0