Should Local Host end with slash "/"

Someone I know is telling me that Apache will automatically appends a forward slash on to the end of either my domain name or Local Host.

But what confuses me is that in my Virtual Host file on my macBook, I have this for the Local Host…

My Macintosh HD: private: etc: hosts as follows…


127.0.0.1 local.one
127.0.0.1 local.debbie

And my Applications: MAMP: conf: apache: httpd.conf as follows…


# Uncommented the line below on 2011-08-13
NameVirtualHost *

# Added on 2011-08-13
<VirtualHost *:80>
# DocumentRoot /Applications/MAMP/htdocs
DocumentRoot "/Users/user1/Documents/DEV/++htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/Users/user1/Documents/DEV/++htdocs/00_AAA"
ServerName local.one
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/Users/user1/Documents/DEV/++htdocs/06_Debbie"
ServerName local.debbie
</VirtualHost>

In essence, what I hear this person saying is that I should have something like this instead…

127.0.0.1 local.one/
127.0.0.1 local.debbie/

What I do know is this…

I normally expect a domain to look like this…

www.MySite.com

…and even the Local Host in my browser during testing should probably be…

local.debbie

…since that is really my “Home Page” locally - and not some empty directory, which is how I would read as local.debbie/

Comments?

Thanks,

Debbie

Do not put directory slashes in hosts files. DNS has no concept of directories.

No No No. My point was, when you visit http://local.debbie, apache is requesting http://local.debbie/ asking for the root web folder (the /) that is defined in your virtual host. It then looks for the default file names you allow (index.html, index.php, etc). Once it finds it, it serves it up, otherwise, it checks if your directory is browseable, and will serve up a directory listing if it is, otherwise you get a 404 or server not found error.

Specifically you were asking about your RewriteRule and your BASE_URL variable in your PHP script.
My point to you was you were confusing your BASE_URL variable in PHP with what Apache see’s as your base web folder, which is local.debbie/. I’ve tried showing this in logs showing that your RewriteRule doesn’t care about the forward slash at the base of your web folder, it only cares about what is after that slash.

Oh well…

And where is it doing that in the code I posted above?

It can’t be doing it here…

My Macintosh HD: private: etc: hosts as follows…


127.0.0.1 local.one
127.0.0.1 local.debbie

BTW, what exactly am I defining there? (I thought I was defining what my Local Host is there, in other words, what address I have to type into the browser so that MAMP serves up my default web page in my Web Root?)

And I’m not sure where it would exist in this code either…

And my Applications: MAMP: conf: apache: httpd.conf as follows…


# Uncommented the line below on 2011-08-13
NameVirtualHost *

# Added on 2011-08-13
<VirtualHost *:80>
# DocumentRoot /Applications/MAMP/htdocs
DocumentRoot "/Users/user1/Documents/DEV/++htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/Users/user1/Documents/DEV/++htdocs/00_AAA"
ServerName local.one
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/Users/user1/Documents/DEV/++htdocs/06_Debbie"
ServerName local.debbie
</VirtualHost>

Again, I am not seeing the mapping of the URL local.debbie to my Web Root, which you are claiming is local.debbie/ :-/

I guess I am not understanding what you are saying?!

It then looks for the default file names you allow (index.html, index.php, etc). Once it finds it, it serves it up, otherwise, it checks if your directory is browseable, and will serve up a directory listing if it is, otherwise you get a 404 or server not found error.

Specifically you were asking about your RewriteRule and your BASE_URL variable in your PHP script.
My point to you was you were confusing your BASE_URL variable in PHP with what Apache see’s as your base web folder, which is local.debbie/. [quote]

I follow you on what you are saying about my PHP Constant called BASE_URL.

But what I still do not see is where I have mapped the URL local.debbie to my Web Root, local.debbie/

Or are you saying that I do NOT have to do that, because Apache assumes that?!

Actually looking above, what I think my code is saying this…

[quote]Define the URL/Local Host as local.debbie

This is the URL from which everything eminates, just like from a URL on the web like www.MySite.com

Now link local.debbie to the physical Web Root folder in NetBeans called ‘/Users/user1/Documents/DEV/++htdocs/06_Debbie’

If nothing is specified in the Browser’s Address Bar after “local.debbie”, then go look for an “index.html” or “index.php” file and serve that up, but still just display local.debbie

If the URL is something like this…

‘local.debbie/usa/arizona/about-phoenix.php’

…then go to the physical Web Root defined above, and look for the file ‘about-phoenix.php’ in the sub-folder called ‘arizona’ in the main folder called ‘usa’

I’m sorry.

This is all new to me and what others have taught me in the past, and I am trying my best… :frowning:

Debbie