xampphttpd.confhtdocs

xampp VirtualHost not working in https-vhost.conf


when i enter ssv2.localhost in my browser (firefox) it will show htdocs folder in xampp . i want to it show "htdocs\shopping_project\v2\files" instead and change the $_SERVER["DOCUMENT_ROOT"] in php to "E:\xampp_8_1_6\htdocs\shopping_project\v2\files" .

what's wrong with this ?

this is my hosts file : (system32)

127.0.0.1 ssv2.localhost

this is my httpd-vhosts.conf : (apache/conf/extra)

<VirtualHost *:80>
 ServerName localhost
 DocumentRoot "E:\xampp_8_1_6\htdocs"
 <Directory "E:\xampp_8_1_6\htdocs">
     DirectoryIndex index.php
 </Directory>
<VirtualHost *:80>
     ServerAdmin original.smm1378@gmail.com
     ServerName ssv2.localhost
     DocumentRoot "E:\xampp_8_1_6\htdocs\shopping_project\v2\files"
     SetEnv APPLICATION_ENV "development"
     <Directory "E:\xampp_8_1_6\htdocs\shopping_project\v2\files">
         DirectoryIndex index.php
         AllowOverride All
         Order allow,deny
         Allow from all        
     </Directory>
 </VirtualHost>

also "Include conf/extra/httpd-vhosts.conf" is not commented in httpd.conf (apache/conf) and i appended this to end of this file :

<Directory />
    AllowOverride none
    Require all granted
</Directory>

i restarted xampp and my system


Solution

  • I just solved my problem like this :

    1 - Add this to first of "apache/conf/extra/httpd-vhost.conf" :

    NameVirtualHost *:80
    NameVirtualHost *:443
    

    2 - And Append (end of file) this to "apache/conf/extra/httpd-vhost.conf" :

    <VirtualHost *:80>
        ServerName localhost
        DocumentRoot "E:\xampp_8_1_6\htdocs"
        <Directory "E:\xampp_8_1_6\htdocs">
            DirectoryIndex index.php
        </Directory>
    </VirtualHost>
    
    <VirtualHost *:443>
        DocumentRoot "E:\xampp_8_1_6\htdocs\shopping_project\v2\files"
        ServerName project_one.localhost
        SSLEngine on
        SSLCertificateFile "conf/ssl.crt/server.crt"
        SSLCertificateKeyFile "conf/ssl.key/server.key"
        <Directory "E:\xampp_8_1_6\htdocs\shopping_project\v2\files">
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    

    3 - Add this to your hosts file (C:\Windows\System32\drivers\etc\hosts) :

    127.0.0.1 ssv2.localhost
    

    4 - Append this to "apache/conf/httpd.conf" :

    <Directory />
        AllowOverride none
        Require all granted
    </Directory>
    

    Now you can access to "E:\xampp_8_1_6\htdocs\shopping_project\v2\files" using url "https://ssv2.localhost" . Hope i helped you .