sub domain not found when using slash in urls

Problems with the Windows version of XAMPP, questions, comments, and anything related.

sub domain not found when using slash in urls

Postby paulcj2 » 01. October 2008 21:01

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?
paulcj2
 
Posts: 6
Joined: 01. October 2008 20:54
Location: Lenox, MA

Postby LooseCannon » 02. October 2008 11:48

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. ;)
User avatar
LooseCannon
 
Posts: 162
Joined: 18. September 2007 12:07
Location: Hampshire, UK

Postby paulcj2 » 02. October 2008 12:08

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.
Last edited by paulcj2 on 02. October 2008 12:14, edited 1 time in total.
paulcj2
 
Posts: 6
Joined: 01. October 2008 20:54
Location: Lenox, MA

Postby glitzi85 » 02. October 2008 12:14

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
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Postby LooseCannon » 02. October 2008 13:40

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. :)
User avatar
LooseCannon
 
Posts: 162
Joined: 18. September 2007 12:07
Location: Hampshire, UK

Postby paulcj2 » 02. October 2008 21:54

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
paulcj2
 
Posts: 6
Joined: 01. October 2008 20:54
Location: Lenox, MA

Postby Sharley » 03. October 2008 05:51

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
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby paulcj2 » 03. October 2008 12:28

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.
paulcj2
 
Posts: 6
Joined: 01. October 2008 20:54
Location: Lenox, MA

Postby Sharley » 03. October 2008 13:59

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
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby paulcj2 » 04. October 2008 01:59

Thanks. Works great now.
paulcj2
 
Posts: 6
Joined: 01. October 2008 20:54
Location: Lenox, MA


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 59 guests