Score:0

How to alias a URL path to another URL path (apache2)?

jo flag

I've tried everything. Alias, ProxyPass, different config files (sites-available/000-default.conf, mods-enabled/alias.conf). My issue is simple. I have an apache2 server hosted at xyz.com/name/. I'd like to alias xyz.com/name so it is treated as xyz.com/name/ and routing works properly.

xyz.com is the main server (university-owned) and proxies requests to xyz.com/name/, which my server is under.

Apache2 web server running on Debian.

Score:0
in flag

Too long for comment

In general: a server has a hostname, such as example.com , not a URI that includes both a hostname and directory path such as example.com/name.

Now there can be a mapping that maps a particular directory path from the server that hosts example.com to a different (back-end) server. That is usually called a reverse proxy (although some appliances/tools implement such mappings slightly differently).

It sounds like your server is the back-end server, let's call that name.internal.example.com.

It is the responsibility of whomever manages example.com to ensure that http(s)://example.com/name/ with a trailing / is mapped the same as http(s)://example.com/name without a trailing /.

Generally it will help when you deploy your content in the same directory that the front-end uses for your content, i.e. in the directory /name

Then http(s)://example.com/name can be mapped to http(s)://name.internal.example.com/name (note that both omit the trailing forward slash) - That usually ensures that when requests such as http(s)://example.com/name/ http(s)://example.com/name/path/to/some/content will also be mapped correctly to your back-end server.

Typically that requires no particular complicated configuration in your apache back-end server. A minimal VitrtualHost block like:

<VirtualHost *:80>
   ServerName name.internal.example.com
   DocumentRoot "/var/www/html" 
</VirtualHost>

and publish your web content in the directory /var/www/html/name

user129393192 avatar
jo flag
Thank you. Could you please add how the person managing `example.com` could ensure trailing `/` is mapped to the same as without trailing `/`? I will accept your answer.
HBruijn avatar
in flag
That completely depends on what technology they use in the reverse proxy. In Apache for example that would typically be `ProxyPass "/name" "http(s)://name.internal.example.com/name"
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.