AgileApps Support Wiki Pre Release

User:Aeric/Apache Notes

From AgileApps Support Wiki
< User:Aeric
Revision as of 21:03, 8 August 2011 by imported>Aeric (→‎mediawiki.conf)

Commands

RedHat commands worth knowing:

  • service httpd restart - Restart Apache (generally unnecessary. Sometimes useful, "just to be sure")
  • service httpd reload - Reload the configuration files

mediawiki.conf

The configuration file for MediaWiki is /etc/httpd/conf.d. mediawiki.conf, where:

  • etc (eht-cee) is the "et cetera" container for stuff added to the system
  • httpd is the HTTP Daemon (Apache)
  • conf.d is the directory of configuration files (all files in this directory are read by Apache when it starts or reloads.)

Warn.png

Important: Everything in that directory is read. So make backup files elsewhere before editing. (Typically in /root.

Contents of that file:

<syntaxhighlight lang="php" enclose="div" style="overflow: auto">
  1. Mediawiki
  2. Allows only localhost by default
  1. CAN'T MATCH THE QUERY STRING:
  2. "The regular expression pattern is matched against the URL-Path of
  3. the incoming request (the part after the hostname but *before* any
  4. question mark indicating the beginning of a query string)."
  5. --so we can easily convert short URLs to MediaWiki long form
  6. --but without a way to parse the query string for its parts,
  7. there is no way to go in the other direction.
    1. RedirectMatch 301 ^/(.+)/index.php?title=(.*)$ /$1/$2
  1. Convert {domain] references to {domain}/wiki references

RewriteEngine on RewriteCond %{REQUEST_URI} !^/wiki/.* RewriteRule ^/(.*)$ /wiki/$1 [PT,QSA] # root => wiki

  1. Point /wiki URLs to the current-version directory

Alias /wiki /usr/share/mediawiki/lj80 <Directory /usr/share/mediawiki/lj80>

  order allow,deny
  allow from all
  # Allow directories to be browsed, except for some that are hidden
  # due to corporate branding or functionality not exposed to ISVs.
  #
  Options Indexes FollowSymLinks MultiViews
  IndexIgnore download/files download/jars download/whitepapers
  # In a directory, the URI does NOT begin with a slash. (Outside, it does.)
  RewriteEngine on                               # "As-Is" Links:
  RewriteRule ^wiki_tests.php - [NC,L]           #   Link-test URL
  RewriteRule ^info.php - [NC,L]                 #   Special-page URL
  RewriteRule ^(images|skins|extensions|download)/ - [NC,L] # Scripts & files
  # Quietly convert short URLs to the long form, so MediaWiki 
  # finds the pages:
  #    index page => 1st MW page
  #    other urls => MW pages
  #    root URL   => 1st MW page
  RewriteRule ^index.php$ index.php?title=Main_Page [NC,L,QSA] 
  RewriteRule ^(.+)$      index.php?title=$1        [NC,L,QSA]  
  RewriteRule ^$          index.php?title=Main_Page [NC,L,QSA]  

</Directory>

Alias /lj80 /usr/share/mediawiki/lj80 Alias /lj81 /usr/share/mediawiki/lj81

<VirtualHost *> ServerName www.platformatyourservice.com DocumentRoot /usr/share/mediawiki/lj80 ServerAlias att.platformatyourservice.com ServerAlias lj.platformatyourservice.com ServerAlias isv.platformatyourservice.com ServerAlias rn.platformatyourservice.com ServerAlias custom.platformatyourservice.com ServerAlias test.platformatyourservice.com </VirtualHost> </syntaxhighlight>

About that query string

Motivation
Pages with plain names seem to work properly. The incoming link is converted to the short URL form, and TOC entries have that form, as well.
But bookmarks that go to old pages that have :, /, or ! in them don't get a URL rewrite, because those characters don't seem to be handled by the URL-segment-at-a-time matching rules. (They must be MediaWiki matching rules, because Apache is *not* doing the redirect. MediaWiki is.)
Idea
We could make a redirect.php page that parses the query string, creates the new URL, and sends a 301-redirect back to the browser. That would be cool. But it's a fair amount of work for a few special pages that, over time, will no longer be bookmarked.