Minghui Yu
Minghui Yu

Reputation: 1363

How to contain a directory (example.com/dir) in Apache conf's Servername setting?

In Apache conf's Servername setting, I need to specify a directory.

Such as Servername www.example.com/directory. I trid and it does not work, though.

I have a main site (www.example.com) which documentroot is /var/www/html/main and my sub site URL is www.example.com/sub and its documentroot is /var/www/html/sub.

Thank you.

Upvotes: 1

Views: 108

Answers (1)

AJ.
AJ.

Reputation: 28174

www.example.com/directory is not a valid value for ServerName. Only hostname and port can be included in the value for ServerName.

What you want to define is called an Alias. You can read about Alias here.

For example, inside of your configuration for www.example.com, you can add this line:

Alias /sub /var/www/html/sub

Upvotes: 3

Related Questions