Reputation: 13
Currently trying to set up a Laravel project on my local PC.I added the hostname 127.0.0.1 localhost-smt to the Windows hostfile and edited my Apache httpd-vhost.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs/project1"
<Directory "C:/xampp/htdocs/project1/">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost-smt
DocumentRoot "C:/xampp/htdocs/project1/smt/public"
ErrorLog "logs/testseite-error.log"
CustomLog "logs/testseite-access.log" common
<Directory "C:/xampp/htdocs/project1/smt/">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
My Apache httpd.conf
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Each time I connect to localhost-smt/home I am receiving a double URL like http://localhost-smt/127.0.0.1/home. Further more if I navigate from localhost to the public folder and add /home i receive the following URL http://localhost/smt/public/127.0.0.1/smt/public/home.
I tried a lot of different solutions, but none of them worked so far. I would appreciate if someone could help me solve this riddle.
Upvotes: 0
Views: 293
Reputation: 1027
I'm not sure how to do this using .conf files but the way I used to achieve this when I used Xampp was as follows, doing it this way will obviously mean undoing anything you have done to the default behaviour of Xampp relating to the .conf files you have edited.
127.0.0.1 dev.projectName
RewriteEngine On RewriteCond %{HTTP_HOST} !^dev.projectName$ RewriteRule .? - [S=1] RewriteRule ^(.*)$ projectName/$1 [L]
RewriteEngine On RewriteBase /dev.projectName/ RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC] RewriteRule ^ %1 [L,NE,R=302] RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
RewriteEngine On RewriteBase /dev.projectName/public/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L]
http:\\dev.projectName
I know it is a long-winded way of doing it but it was the only solution I could find at the time and it worked for me.
It does become a ball-ache having to do this every time you create a new project which is one of the reasons I switched to docker which in my opinion is a much better solution anyway,
Upvotes: 0