Skip to main content

Virtual Host on a sub directory [Resolved]

This question already has an answer here:

I m working on a web project and there a requirement that it works good on top domain, and on a domain+directory paths like this:

www.myDomain.com
www.myDomain.com/somedir/myproject/

The project deals with well with include files,

But i fail to setup my VHosts to test the second case www.myDomain.com/somedir/myproject/

My current setup is as simple as possible:

hosts

127.0.0.1       www.myDomain.com

httpd-vhosts.conf

NameVirtualHost *:80

  Order Deny,Allow
  Allow from all



  DocumentRoot C:\wamp\www
  ServerName localhost
   


    DocumentRoot "C:\Projects\MyProject\public_html"
    ServerName  "www.myDomain.com"


#@ToDo make this work ...
#
#    DocumentRoot "C:\Projects\MyProject\public_html"
#    ServerName  "www.myDomain.com/somedir/myproject/"
#

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php [NC,L]

Can i do this just with Virtual host ? What is the best practice to achieve this setup on local machine?


Question Credit: d.raev
Question Reference
Asked April 14, 2019
Posted Under: Network
41 views
1 Answers

Your Answer