Page 1 of 1

sub domain not found when using slash in urls

PostPosted: 01. October 2008 21:01
by paulcj2
Re: Adding the slash to the href on my development server no longer pointed to the clickbasics virtual host
http://localhost/clickbasicsdemo/index.php/
but to
http://localhost/index.php/
I need to do this as such is how it works best on my public server.

Here is my development server apache virtual host setting in apache/conf/extra/httpd-vhosts.conf

Code: Select all
<VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot "C:\xampp\htdocs\clickbasicsdemo"
            ServerName clickbasicsdemo
           
            CustomLog "C:\xampp\htdocs\clickbasicsdemo\logs\clickbasicsdemo.local.access.log" combined
    ErrorLog "C:\xampp\htdocs\clickbasicsdemo\logs\clickbasicsdemo.local.error.log"
           
            <Directory C:\xampp\htdocs\clickbasicsdemo>
            ##IndexOptions +FancyIndexing NameWidth=*
            Options Includes FollowSymLinks Indexes
            AllowOverride All
            Order allow,deny
            Allow from all
            </Directory>
</VirtualHost>


Here is my Windows XP host setting in C:\WINDOWS\system32\drivers\etc

Code: Select all
127.0.0.1       localhost.clickbasicsdemo

What am I missing?

PostPosted: 02. October 2008 11:48
by LooseCannon
Hello and welcome paulcj2.

"127.0.0.1 localhost.clickbasicsdemo" is for a domain "localhost.clickbasicsdemo", which doesn't exist (from the info you've provided).

You have in effect two domains on your PC - localhost and, separately, clickbasicsdemo.

Therefore, you need two lines in the host file:

127.0.0.1 localhost
127.0.0.1 clickbasicsdemo

The vhost setup for clickbasicsdemo looks ok, but I've not really checked it. Let's see how the host file change helps,,,, or not. ;)

PostPosted: 02. October 2008 12:08
by paulcj2
Actually, I showed only one line. All the lines are:
Code: Select all
127.0.0.1       localhost
127.0.0.1       localhost.phpmyadmin
127.0.0.1       localhost.clickbasics
127.0.0.1       localhost.clickbasicsdemo
127.0.0.1       localhost.kriapalu
127.0.0.1       localhost.lyyd_test

Are you saying they should be as follows?
Code: Select all
127.0.0.1       localhost
127.0.0.1       phpmyadmin
127.0.0.1       clickbasics
127.0.0.1       lclickbasicsdemo
127.0.0.1       kriapalu
127.0.0.1       lyyd_test

I tried that and it made no difference.

PostPosted: 02. October 2008 12:14
by glitzi85
paulcj2 wrote:Are you saying they should be as follows?

Yes! You must use the same Value for ServerName as you did in the hosts-File.

glitzi

PostPosted: 02. October 2008 13:40
by LooseCannon
I tried that and it made no difference.

Typing or editing error?

"127.0.0.1 lclickbasicsdemo"

Should be:

"127.0.0.1 clickbasicsdemo"

As glitsi85 states, it must be the same value.

Note that you can have vhosts with a dot, eg clickbasics.local, but the vhost file should read "ServerName clickbasics.local".

Please let us know how you get on. :)

PostPosted: 02. October 2008 21:54
by paulcj2
I tried in the hosts file both:

Code: Select all
127.0.0.1       localhost
127.0.0.1       localhost.clickbasics

and
Code: Select all
127.0.0.1       localhost
127.0.0.1       clickbasics

and the server name respectively both

Code: Select all
ServerName localhost.clickbasicsdemo

and
Code: Select all
ServerName clickbasicsdemo

It made no difference

PostPosted: 03. October 2008 05:51
by Sharley
http://localhost/clickbasicsdemo/index.php/

You have a folder called index.php in the .\xampp\htdocs\clickbasicsdemo folder?

Surely not.

Just use http://localhost/clickbasicsdemo/index.php no slash at the end, as that denotes another folder and the server will look for an index file in that folder and if non exists it will give you a file listing.

And as mentioned by the previous posters the Windows Hosts file entries should mirror your ServerName entries in your configuration file.

To test your vhosts configuration file for correct syntax run the command apache -S from a command prompt in the .\xampp\apache\bin folder.

If you would like me to take a look at the full vhosts configuration file for you then please feel free to paste it here or PM me.

Good luck.
Sharl

PostPosted: 03. October 2008 12:28
by paulcj2
You have a folder called index.php in the .\xampp\htdocs\clickbasicsdemo folder?

no

Just use http://localhost/clickbasicsdemo/index.php no slash at the end...

Works fine.

Windows Hosts file entries should mirror your ServerName entries in your configuration file.

Yes
Code: Select all
run the command apache -S from a command prompt in the .\xampp\apache\bin folder.

Done

Code: Select all
C:\Documents and Settings\Owner>cd ../../

C:\>cd xampp/apache/bin

C:\xampp\apache\bin>apache -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          localhost (C:/xampp/apache/conf/extra/httpd-ssl.conf:74)
*:80                   is a NameVirtualHost
         default server localhost (C:/xampp/apache/conf/extra/httpd-vhosts.conf:
44)
         port 80 namevhost localhost (C:/xampp/apache/conf/extra/httpd-vhosts.co
nf:44)
         port 80 namevhost phpmyadmin (C:/xampp/apache/conf/extra/httpd-vhosts.c
onf:50)
         port 80 namevhost clickbasics (C:/xampp/apache/conf/extra/httpd-vhosts.
conf:56)
         port 80 namevhost localhost.clickbasicsdemo (C:/xampp/apache/conf/extra
/httpd-vhosts.conf:69)
         port 80 namevhost kripalu (C:/xampp/apache/conf/extra/httpd-vhosts.conf
:86)
         port 80 namevhost lyyd_test (C:/xampp/apache/conf/extra/httpd-vhosts.co
nf:92)
Syntax OK


If you would like me to take a look at the full vhosts configuration file for you then please feel free to paste it here or PM me.

Code: Select all
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##    ServerAdmin webmaster@dummy-host.example.com
##    DocumentRoot /www/docs/dummy-host.example.com
##    ServerName dummy-host.example.com
##    ServerAlias www.dummy-host.example.com
##    ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common
##</VirtualHost>

##<VirtualHost *:80>
##    ServerAdmin webmaster@dummy-host2.example.com
##    DocumentRoot /www/docs/dummy-host2.example.com
##    ServerName dummy-host2.example.com
##    ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
##</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot "C:\xampp\htdocs"
   ServerName localhost
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot "C:\xampp\phpmyadmin"
   ServerName phpmyadmin
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot "C:\xampp\htdocs\clickbasics"
   ServerName clickbasics
   <Directory C:\xampp\htdocs\clickbasics>
   IndexOptions +FancyIndexing NameWidth=*
   Options Includes FollowSymLinks Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
   </Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot "C:\xampp\htdocs\clickbasicsdemo"
   ServerName localhost.clickbasicsdemo
   
   CustomLog "C:\xampp\htdocs\clickbasicsdemo\logs\clickbasicsdemo.local.access.log" combined
    ErrorLog "C:\xampp\htdocs\clickbasicsdemo\logs\clickbasicsdemo.local.error.log"
   
   <Directory C:\xampp\htdocs\clickbasicsdemo>
   ##IndexOptions +FancyIndexing NameWidth=*
   Options Includes FollowSymLinks Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
   </Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot "C:\xampp\htdocs\kripalu"
   ServerName kripalu
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot "C:\xampp\htdocs\lyyd_test"
   ServerName lyyd_test
</VirtualHost>


I have tried both localhost.clickbasicsdemo and clickbasicsdemo in both places at the same time.

PostPosted: 03. October 2008 13:59
by Sharley
phpMyAdmin is covered by an alias in C:\xampp\apache\conf\extra\httpd-xampp.conf and so there is no need for a vhost entry nor an entry in your Hosts file as this may conflict.

Your slashes are the wrong way for an apache config file - see the commented examples in your vhosts file.


Here is a copy and paste vhosts conf file for you that may help.
Let me know back if you have any more issues with it.
You can delete my comment about the logs directory in the file when you have checked it out.
Also if you copy and paste then just delete the first instance of the NameVirtualHost *:80 in your vhosts file as 2 entries may give errors.
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs"
ServerAdmin webmaster@localhost
</VirtualHost>


<VirtualHost *:80>
ServerName clickbasics
DocumentRoot "C:/xampp/htdocs/clickbasics"
ServerAdmin webmaster@localhost
<Directory "C:/xampp/htdocs/clickbasics">
IndexOptions +FancyIndexing NameWidth=*
Options Indexes Includes FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


<VirtualHost *:80>
ServerName clickbasicsdemo
DocumentRoot "C:/xampp/htdocs/clickbasicsdemo"
ServerAdmin webmaster@localhost
<Directory "C:/xampp/htdocs/clickbasicsdemo">
##IndexOptions +FancyIndexing NameWidth=*
Options Includes FollowSymLinks Indexes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
CustomLog "C:/xampp/htdocs/clickbasicsdemo/logs/clickbasicsdemo.local.access.log" combined
ErrorLog "C:/xampp/htdocs/clickbasicsdemo/logs/clickbasicsdemo.local.error.log"
## Make sure the logs file directories exist
</VirtualHost>   


<VirtualHost *:80>
ServerName kripalu
DocumentRoot "C:/xampp/htdocs/kripalu"
ServerAdmin webmaster@localhost
</VirtualHost>


<VirtualHost *:80>
ServerName lyyd_test
DocumentRoot "C:/xampp/htdocs/lyyd_test"
ServerAdmin webmaster@localhost
</VirtualHost>


Hosts file:
Code: Select all
127.0.0.1       localhost
127.0.0.1       clickbasics
127.0.0.1       clickbasicsdemo
127.0.0.1       kriapalu
127.0.0.1       lyyd_test


http://localhost/
http://clickbasics/
http://clickbasicsdemo/
http://kriapalu
http://lyyd_test/

The above URIs will display the index file if it exists in their respective folders or a file listing if no index file is present.

For your info I have included here a typical sub domain for one of your above domains - just change the name subdomain to one of your choice, forums for example:
Code: Select all
<VirtualHost *:80>
ServerName clickbasics
ServerAlias subdomain.clickbasics
DocumentRoot "C:/xampp/htdocs/clickbasics/subdomain"
ServerAdmin webmaster@localhost
<Directory C:/xampp/htdocs/clickbasics/subdomain>
IndexOptions +FancyIndexing NameWidth=*
Options Indexes Includes FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Hosts file:
Code: Select all
127.0.0.1 subdomain.clickbasics

http://subdomain.clickbasis/

HTH
Sharl

PostPosted: 04. October 2008 01:59
by paulcj2
Thanks. Works great now.