I have a strange problem in accessing to virtual host in WAMP
.
I have defined my virtual host (it calls mvc.dev
) by defining in server configuration
page in wampserver
. Steps are exact that I have explained in the following:
1- first, going to server configuration page and select Add a virtual host
2- As index.php
in my project is in C:\wamp64\www\mvcdev\public path
, so I fill out related fields for my virtual host and then start to creation of virtual host.
3- It is created correctly and wamp server wants to restart DNS manually. I restarted it from wamp server menu like this:
4- After restarting, I check localhost page. It shows that mvc.dev
is created correctly without any problem
5- And the problem occurs here, when I click on mvc.dev or type it in address bar of browser to access my virtual host, it causes to download a file instead of loading index.php file. I'm so frustrated about this issue and I don't know how can I solve this. Why does it cause to download hex file instead of executing URL?
This file is a hex file and every time that I put mvc.dev
in url, it will start to download this file
For your information, I have also tested it by defining virtual host manually. I put related codes in httpd-vhosts.conf
and then define mvc.dev in host
and then restart DNS
, but the result is the same with thing that I have explained before and I can not access to my virtual host at all. You can see it in the following:
configuration in host
file:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 mvc.dev
::1 mvc.dev
configuration of httpd-vhosts.conf
:
#
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName mvc.dev
DocumentRoot c:/wamp64/www/mvcdev/public
<Directory "c:/wamp64/www/mvcdev/public/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
How can I solve this problem?
Note: I also checked this one by one but I couldn't solve my problem: project-links-do-not-work-on-wamp-server
The .htaccess
file is
# Remove the question mark from the request but maintain the query string
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
The code in index.php
is
echo 'Request URL is: '.$_SERVER['QUERY_STRING'];
//require '../core/Router.php';
require "../vendor/autoload.php";
$router = new Core\Router();
$router->add('/','HomeController@index');