How to mount a Basic VirtualHost to rewrite URLs in my project in Xampp htdocs

1

Following the proposed model in the link file itself

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
    
asked by anonymous 25.05.2018 / 14:20

2 answers

1

It would look like this:

<VirtualHost projeto:80>
    ServerAdmin webmaster@projeto
    ServerName projeto

    DocumentRoot "C:/xampp/htdocs/projeto"
    <Directory C:/xampp/htdocs/projeto>
        AllowOverride None
        Order Allow,Deny
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php [QSA,L]
        </IfModule>
    </Directory>

</VirtualHost>

Then add the name "project" to your host. As you are in the Windows environment: C: \ Windows \ System32 \ drivers \ etc \ hosts

   127.0.0.1     projeto
    
25.05.2018 / 14:27
1

Duplicate this line and configure as needed in the Httpd-vhosts.conf file. Do not forget to enable the vhost module in Httpd.conf, release the listen to the port of the new virtual host that you have configured (these lines are sometimes commented with #).

Watch out for the lines below:

Httpd.conf file :

Listen 81
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include conf/extra/httpd-vhosts.conf

Restart your XAMP

    
25.05.2018 / 14:32