-1

I have set up my virtual hosts with xampp.

I uncommented the vhosts line in the httpd.conf file and added the virtual hosts in the vhosts document. The files for the web pages are located in my htdocs folder (two separate folders for each page within the htdocs folder, was using the Documents folder but had permission errors).

I changed the hosts file as well, but when I try to access the page using 'http://pagename.local' instead of getting the page, I get an index which says:

Index of /

Name etc etc etc

pagename.local1

So i believe its giving me the index of the folder instead of the page?

My vhosts conf looks like this:

<VirtualHost 127.0.0.1>
   DocumentRoot C:/Users/xxxxxx/Documents/xampp/htdocs/pagename1
   ServerName pagename1.local
</VirtualHost>

<VirtualHost 127.0.0.1>
   DocumentRoot C:/Users/xxxxxx/Documents/xampp/htdocs/pagename2
   ServerName pagename2.local
</VirtualHost>

also if I click on the pagename1.local in the index, it does take me to the page and in the url it displays: pagename1.local/pagename1.local.

Ladadadada
  • 26,337
  • 7
  • 59
  • 90
  • thank you for the advice but to be honest a lot of my questions didn't receive an answer that fixed my problem so i'm not quite sure if i should accept something or not? –  Oct 23 '12 at 08:25

2 Answers2

0

Questions:

What is the result when you in cmd do the following?

 ping pagename1.local
 ping pagename2.local

If those two pings works, this should work, if not, please look into the apache error.log

<VirtualHost *:80>
   ServerName pagename1.local
   ServerAlias pagename1.local
   DocumentRoot "C:/Users/xxxxxx/Documents/xampp/htdocs/pagename1"
   <Directory "C:/Users/xxxxxx/Documents/xampp/htdocs/pagename1">
            Order deny,allow
            Allow from all
            AllowOverride All
   </Directory>
 </VirtualHost>

 <VirtualHost *:80>
   ServerName pagename2.local
   ServerAlias pagename2.local
   DocumentRoot "C:/Users/xxxxxx/Documents/xampp/htdocs/pagename2"
   <Directory "C:/Users/xxxxxx/Documents/xampp/htdocs/pagename2">
            Order deny,allow
            Allow from all
            AllowOverride All
   </Directory>
 </VirtualHost>
donald123
  • 101
  • 2
  • the pinging works fine i think. i don't understand what the big piece of code there is? are you suggesting i put that into my code? –  Oct 23 '12 at 08:26
  • replace your code width my one and restart your apache .. –  Oct 23 '12 at 08:28
  • I tried your code and it still takes me to the index. –  Oct 23 '12 at 08:42
  • In your httpd.conf what are the values of a)ServerName, b) Listen –  Oct 23 '12 at 08:52
  • And in your httpd-vhosts.conf the only code is the above one? –  Oct 23 '12 at 08:53
  • Servername is localhost:80, and Listen is 80. In my vhosts conf i also have one more virtual host for localhost which has a document root at htdocs and server name localhost –  Oct 23 '12 at 09:13
  • please remove all vhost in your httpd-vhosts and try it with the above code ... in your directory e.g C:/Users/xxxxxx/Documents/xampp/htdocs/pagename2 is there a index.html or index.php? –  Oct 23 '12 at 09:16
  • Tried it again and the code still took me to an index. I don't have any index pages in my directories, all I have is each web page in their own folder. –  Oct 23 '12 at 09:26
  • >>I don't have any index pages in my directories<< sorry i didn't understand what you are trying .. without any files in the DocumentRoot you get the index while you not disable it by Options -Indexes in your VirtualHost Directory ... –  Oct 23 '12 at 09:34
  • I mean inside my documentroot i only have page1.local, i dont have any index.html or index.php –  Oct 23 '12 at 09:45
0

Is C:/Users/xxxxxx/Documents/xampp/htdocs/pagename1/pagename1.local a file or a directory?

If it's a file, change it to index.html (or whatever your DirectoryIndex is).

If it's a directory, either change your DocumentRoot to that directory or move its contents up one level.

Ladadadada
  • 26,337
  • 7
  • 59
  • 90