smarber
smarber

Reputation: 5074

add alias to my virtual host

I've deployed my project symfony2 on a personal server and everything works fine.

Now I want to publish this project for some friends so that they can see it. I thought that the best would be to access my project from outside through /. Quick google research made think that it's possible with Alias statement.

ServerName blabla
ServerAlias blablab
ServerAdmin blablab@blabla
DocumentRoot /path/to/my/project/web     

Alias /myproject "/path/to/my/project/web"
<Directory /path/to/my/project/web>
   DirectoryIndex app.php
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Require all granted
   Order allow,deny
   allow from all
</Directory>

When I try to access <server_IP_ADDRESS>/<project_name> I got Not found error

Why this error? How do I fix this ?

UPDATE1

I have many projects on one server, and I'd like to be able to access them anywhere I'm. The best option from my point of view is to use Aliases:

  1. project1: http://<my_server_ip_address>/project1
  2. project2: http://<my_server_ip_address>/project2
  3. project3: http://<my_server_ip_address>/project3 ....

Upvotes: 0

Views: 255

Answers (1)

php_nub_qq
php_nub_qq

Reputation: 16017

Having a virtual server will map a server to a host name / alias. In your case you are accessing the same host name (the server ip) but different URIs. In your case these URIs may not exist, thus you need to redirect/rewrite them. I think you would be looking for rewrite so you can just go ahead and put rewrite rules in the virtual host definition as in .htaccess just make sure you have mod_rewrite enabled.

ServerName <server ip>

RewriteEngine On

RewriteRule /project1 /Path/to/project/1 [L]
RewriteRule /project2 /Path/to/project/2 [L]
RewriteRule /project3 /Path/to/project/3 [L]

Upvotes: 1

Related Questions