mod_rewrite messing up Header/Stylesheets

I still have to revisit this today, but I still don’t see why using my original approach was wrong…

Having an intelligent Config file that changes where the ROOT and WEB_ROOT is located based on whether you are in “Development” or “Production” has made my life so much easier since I originally started having problems with Relative HTML Links.

(And in fact I’m still not entirely sure I won’t still have to use my Config file?!)

The only problem I had out of all of this - as a result of my Mod_Rewrite - was/is the problem with links to my pictures in my Articles. (And I don’t think this is an issue of my Config file vs. using a Virtual Host. I think it is an issue that I STILL have some major issues getting my PHP articles into MySQL and working properly, which is another thread…) :frowning: :frowning:

Debbie

Dan and Ralph,

I would like to make certain that I understand how this Virtual Host thing is supposedly working. (If you could check this out, I’d appreciate the help!)

Here is what I did/have…

1.) Used TextWrangler to modify Macintosh HD: private: etc: hosts as follows…


## Added 2011-08-13
127.0.0.1 local.one
127.0.0.1 local.dev

This points the host names “local.one” and “local.dev” to my local computer, right?

2.) Used TextWrangler to modify 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/01_MyProject"
  ServerName local.dev
</VirtualHost>

This connects the Host Names to the directories which hold the physical files, right?

3.) In NetBeans I have the following settings…

Project Folder:
/Users/user1/Documents/DEV/++htdocs/01_MyProject

Source Folder
/Users/user1/Documents/DEV/++htdocs/01_MyProject

This is where my physical files exist, right?

Web Root
<Source Folder>

Project URL
http:// local.dev/

This is what you type in the browser to launch the mapped physical files above, right?

Index File
index.php

And when I am in each respective NetBeans Project Folder and I hit Shift + F6, it seems like the Project and Project Files seem to work properly…


So putting all of this together…

Originally, because NetBeans stores my files in a project folder, that changes what the “Web Root” actually is. And it is different than what is on a normal production server like on my web host, GoDaddy.

So that was messing up my paths, especially when it came to how mod_rewrite works and how HTML relative links work.

Is that correct?

Now by creating a Virtual Host, I am able to tell Apache to still point to the same physical files which are nested within my NetBeans Project Folder, however, the Virtual Host lets me program my website like the NetBeans Project Folder is not there, and so I can use the same code and paths that I would use on my GoDaddy account?

Did I get that right?

Still trying to put all of this together, AND make sure I understand it completely before I go back and change all of my code to work with Virtual Hosts and possibly break things even more so?! :eek: :eek:

Thanks,

Debbie

As far as I can tell you hit the nail on the head there, in all the points above!! Nothing to add / change, the answer to all questions is “indeed, that’s correct” :slight_smile:

Cool! One step closer towards “greatness” like all of you guys and gals!! :smiley:

Debbie