Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Demagonn's avatar

How to run correctly an virtualhost wamp + laravel ?

hi

Since few hours i try to run a virtualhost correctly. I have : windows 10 64b wamp 32b laravel 5.4

In my C:\Windows\System32\drivers\etc\hosts :

127.0.0.1       localhost
::1             localhost
::1             perso.dev
127.0.0.1   perso.dev

In my C:\wamp\bin\apache\apache2.4.23\conf\httpd.conf :

#Virtual hosts
Include conf/extra/httpd-vhosts.conf

In my C:\wamp\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf

# Virtual Hosts
#

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "C:/wamp/www"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerName perso.dev
   DocumentRoot "C:/wamp/www/persosite/public"
   <directory "C:/wamp/www/persosite/public">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </directory>
</VirtualHost>

in my C:\wamp\www\persosite\public\ .htaccess :

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>]

When i go to the home page i have always this url perso.dev/index.php How can i remove index.php ? When i go to the article page i have always this url perso.dev/index.php/article AND no css, no js, no img How can i fix this ?

Thank you

0 likes
6 replies
lara65535's avatar

Step 1: All of your forward back slashes should be forward slashes.

Step 2: You don't need to set the env as Laravel's .env does that for you with APP_ENV

Step 3: Add ::1 perso.dev to your windows hosts file

Step 4: Remove directory index.php

Here is what my virtual host looks like

<VirtualHost *:80>
    ServerName master.mysite.dev
    DocumentRoot "c:/my-site/master-branch/public"
    <Directory  "c:/my-site/master-branch/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

and your .htaccess file should look similar to this...

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Snapey's avatar

everything looks ok with your vhosts. I would suspect your .htaccess compared to the default for laravel

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

oh, and make sure the rewrite module is installed and enabled

Demagonn's avatar

Hi thank you for the help

  • Step 1: All of your forward back slashes should be forward slashes.==> done

  • Step 2: You don't need to set the env as Laravel's .env does that for you with APP_ENV ==> done

  • Step 3: Add ::1 perso.dev to your windows hosts file ===> done

  • Step 4: Remove directory index.php ===> done

  • Virtualhost ==> changed

  • htaccess ===> changed

Problem still here : When i go to perso.dev my browser go automatically to perso.dev/index.php

BUT now i can go to perso.dev/article with all content and no error.

I have update my first post with my currents files

Snapey's avatar

for future reference please don't edit the original post in this way. It makes the original answers look stupid and someone new to the thread might read through your question and not see anything wrong.

there is no 'cost' with posting new versions of your code so that people can follow along

Demagonn's avatar
Demagonn
OP
Best Answer
Level 1

Problem solved. My rewrite_module was activated but if delete wamp and try with the same code on xamp and all work fine. I don't know why wamp doesn't work...

Please or to participate in this conversation.