Apache alias in .htaccess (mod rewrite question)

Btw if you’re really running MySource Matrix, forget a shared webhosting account. Think big fat dedicated server(s).

It’s been done before, trust me on that one. I’m using an older version 3.2.2, which supports MySQL and has been installed on shared hosts with apache 2.x. I manage several dedicated installations of matrix, but haven’t managed to come up with a solution for running a personal site with it.

@extras, thanks for the advice. I’d have to setup a debian system to run that, so I’m getting into the realm of ‘is it worth the trouble?’. Great workaround though.

Oh, I was thinking of recent MySource Matrix.

Nope, it’s almost the opposite. PHP running as apache module will take these:

http://example.com/articles/foo-bar

or

http://example.com/index.php/articles/foo-bar

but PHP running as CGI won’t accept those sorts of path_info. Instead, it likes this:

http://example.com/index.php?/articles/foo-bar

LinhGB,

I just tested with PHP running with cgi, and with CGI.

env.php


<pre><? print_r($_SERVER); ?>

http://example.com/env.php/asd/wrw

[QUERY_STRING] =&gt;
[REQUEST_URI] =&gt; /env.php/asd/wrw
[SCRIPT_NAME] =&gt; /env.php
[PATH_INFO] =&gt; /asd/wrw

At least on PowWeb server, it seems to work, just like normal CGI.

env.cgi


#!/bin/sh
echo
printenv|sort

http://example.com/env.cgi/asd/wrw
QUERY_STRING=
REQUEST_URI=/env.cgi/asd/wrw
SCRIPT_FILENAME=/www/X/X/XXXXX/htdocs/env.cgi
SCRIPT_NAME=/env.cgi

Interesting. I’ll get back to you on that.

I know this post is old, though for the benefit of anyone that comes across this page, I found the equivalent to doing the alias rule in .htaccess (since apache states that you cannot in the documentation [unable to post url]) is to use the RewriteRule method.

So if you wanted to do this

alias /old-folder /new-folder

With RewriteRule, which you place at the top of your .htaccess (or before any other RewriteRules), you would have

RewriteRule /old-folder /new-folder [PT]

The [PT] flag is to Pass Through the rule, which basically means that the URL which is used by the system becomes changed as if the user had put in the new url themselves.

If your RewriteRule fails, check that the

  1. apache module is installed
  2. is enabled via
    RewriteEngine On
    ; and
  3. correct syntax is used (as it uses regular expressions)

Hope it helps your question.