Login required to started new threads

Login required to post replies

OT: Apache Help
Quote | Reply
If there are any Apache experts out there, I need some help.

I am using Apache to run a development environment on my computer. I have several sites that I am developing, each of which has their own folder in the htdocs root folder.

My question is, how do I get references to the site root to only go to the folder root, rather to htdocs.

That is, I have htdocs/foo. Inside foo, I have a folder images. When loading images on a page, I refer to src="/images/bar.gif". But of course, this bounces to htdocs to look for the images folder, which I don't want.

So either I need to set it so that it looks for the root within each specific site folder, or I need to somehow create an name-address or IP for each folder so I'm not accessing them as localhost/foo. I guess the latter would require configuring a DNS on my computer?

Any help? I am continually amazed by the knowledge of all Slowtwitchia...

"Non est ad astra mollis e terris via." - Seneca | rappstar.com | FB - Rappstar Racing | IG - @jordanrapp
Quote Reply
Re: OT: Apache Help [Rappstar] [ In reply to ]
Quote | Reply
Quote Reply
Re: OT: Apache Help [Rappstar] [ In reply to ]
Quote | Reply
If I am understanding your question correctly this is what you are trying to accomplish:

you have a directory tree that looks like:
../htdocs/foo/images
and in your html you have image references that look like
/images/whatever.jpg
The solution is to either drop the first slash:
images/whatever.jpg
Or use an absolute path:
/htdocs/foo/images/whatever.jpg

This assumes that htdocs is at the root. I am running apache on a Linux box and my web document root is called html, so an absolute path looks like:
/var/www/html/foo/images/whatever.jpg

If this doesn't make sense pm me more details (platform would be nice to know) and I'll try a better answer.

-Joey
www.theraceguide.com
Quote Reply
Re: OT: Apache Help [Rappstar] [ In reply to ]
Quote | Reply
I am continually amazed by the knowledge of all Slowtwitchia...


*** So am I. And sometimes it makes me feel like a complete dumbass. You're post was in English. I'm fairly certain. But I didn't understand a thing you wrote.

*****
"In case of flood climb to safety"
Quote Reply
Re: OT: Apache Help [Rappstar] [ In reply to ]
Quote | Reply
it should not show htdocs/images/foo.gif in the html request if that IP address is mapped right to a propagated domain name. Your domain name, after it gets propagated and set, would = htdocs, or public_html. htdocs would not show in a browser surfing to your website.

The directory htdocs should not show in html requests, nor would public_html or whatever in free beastie, etc.
Quote Reply
Re: OT: Apache Help [Rappstar] [ In reply to ]
Quote | Reply
I would recommend using virtual hosts. If you are only doing things on your local computer, you should *not* have to configure DNS. You can cheat and just hack up your hosts file. On windows, this is usually under:
c:\$winhome\system32\drivers\etc

Add you "fake" names under the localhost setting
127.0.0.1 localhost
127.0.0.1 foo.bar
127.0.0.1 me.slowtwitch.com

On unix/linux, this file is /etc/hosts

After you make the change and save the file, do a quick ping test.
1. Open up a command/terminal window
2. run the following:
ping my-fake-name.something.or.another

Example:
ping me.slowtwitch.com
PING me.slowtwitch.com (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=128 time=0 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=128 time=0 ms


This would be bad output (aka you did something wrong)
ping you.slowtwitch.com
ping: unknown host you.slowtwitch.com




As for apache, setup the vhosts something like this:
[..]
<VirtualHost *:80>
ServerAdmin foo@bar.com
DocumentRoot /home/www/twothirds.org
ServerName twothirds.org
ServerAlias www.twothirds.org
ErrorLog logs/twothirds-error_log
CustomLog logs/twothirds-access_log combined
<Directory "/home/www/twothirds.org">
Options Indexes FollowSymLinks Includes
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerAdmin foo@bar.com
DocumentRoot /home/www/70.3athlete.com
ServerName 70.3athlete.com
ServerAlias ironman70.3athlete.com
ErrorLog logs/70.3athlete-error_log
CustomLog logs/70.3athlete-access_log combined
<Directory "/home/www/70.3athlete.com">
Options Indexes FollowSymLinks Includes
AllowOverride All
</Directory>
</VirtualHost>
[..]


As an alternative, you might be able to write custom mod_rewrite rules, but that can be very unfun.

--
http://twothirds.org/
Quote Reply
Re: OT: Apache Help [twothirds] [ In reply to ]
Quote | Reply
Thanks. This is EXACTLY what I was looking for. I wasted an extra hour after changing the windows hosts file, because once I configured the virtual hosts, I forgot I had to restart Apache... So I was close to going crazy until I had that minor epiphany, and then voila, just as you said... So THANK YOU for your help!

"Non est ad astra mollis e terris via." - Seneca | rappstar.com | FB - Rappstar Racing | IG - @jordanrapp
Quote Reply