Home > Mobile >  set virtualhost in apache is not direct to my goal directory of laravel project
set virtualhost in apache is not direct to my goal directory of laravel project

Time:10-19

OS: Microsoft Windows 10

backend framework: Laravel

my goal: when I access to "http://example.domain", it can direct to laravel index.php.

httpd-vhosts.conf:

<VirtualHost *:80>
    DocumentRoot "C:\Apache24\htdocs\NKUST_foodpanda\public"
    DirectoryIndex index.php
    ServerName example.domain
    ErrorLog "C:\Apache24\logs\error.log"
    CustomLog "C:\Apache24\logs\access.log" combined
    <Directory "C:\Apache24\htdocs\NKUST_foodpanda\public"> 
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

I save httpd-vhosts.conf and restart my apache, and now, when I access to "http://example.domain", it will direct to "C:\Apache24\htdocs", not "C:\Apache24\htdocs\NKUST_foodpanda\public".

CodePudding user response:

I have tried with same possible scenario as yours with following entry httpd-vhost.conf. Checked it with both '' and '/' and it is working for me. Make sure to provide proper permission to your directories. If this could not work you need to provide more info.

    <VirtualHost example.domain:80>
      DocumentRoot "C:\Apache24\htdocs\NKUST_foodpanda\public"
      DirectoryIndex index.html
      ServerName example.domain
      ErrorLog "C:\Apache24\logs\error.log"
      CustomLog "C:\Apache24\logs\access.log" combined
      <Directory "C:\Apache24\htdocs\NKUST_foodpanda\public"> 
        Options FollowSymLinks
        AllowOverride All
        Require all granted
      </Directory>
    </VirtualHost>

CodePudding user response:

If you want to set a newer setup in "httpd-vhosts.conf", you have to delete comment out "Include conf/extra/httpd-vhosts.conf" in "httpd.conf".

I have not notice this problem, I comment out "Include conf/extra/httpd-vhosts.conf" and set something in "httpd-vhosts.conf" at the same time, so "httpd-vhosts.conf" doesn't work.

  • Related