Forum Moderators: phranque

Message Too Old, No Replies

Local Dev Directory Woes

         

WebDeveloper1981

6:42 pm on Dec 15, 2006 (gmt 0)

10+ Year Member



First, some specs: Windows XP SP2 / Apache 1.3.37 / PHP 4.4.4

Like most web developers, I develop and test sites locally, then upload them to public servers when they're ready. Sites that I build from scratch use relative paths, so moving them around is easy. It's when I have to work with _other_ people's code that things can get ugly.

For example, a site I'm working on today is full of hyperlinks that start with "/". I access the site on my local machine by going to:

[localhost...]

The problem is that links on index.php that start with "/" resolve to:

[localhost...]

This is true even when using HTML base tags. :-(

One solution I know would work would be for me to trudge through the dozens upon dozens of PHP scripts that make up the site, identifying every link (many are dynamically generated - and don't forget about linked style sheets and JavaScripts, images, etc.) and make them all relative, like they should've been in the first place!

What I'd like to do is to somehow tell Apache that [localhost...] is that site's root. (Or can I map a DynDNS hostname to a specific subdirectory on my machine?)

I'm looking at my configuration, and I can't imagine that I'm the only person to have ever encountered this problem.

Any insight would be GREATLY appreciated. This is an issue I've been trying to tackle for a long time.

equalm

6:53 pm on Dec 15, 2006 (gmt 0)

10+ Year Member




well, you can always add in a simple rewrite, that's more like a hack, but it gets the job done

RewriteCond %{REQUEST_URI} !^/sitename
RewriteRule ^/(.*) /sitename/$1 [PT]

but do you have multiple "sitename" folders under the docroot? Then this hack will only work with one sitename at a time, but that should serve the purpose if working with this site and being done with it. Just comment it out when you're finished.

.

WebDeveloper1981

7:55 pm on Dec 15, 2006 (gmt 0)

10+ Year Member



@equalm

Thanks for the suggestion. I do have other sites in my document root, but temporarily adding a few lines to an .htaccess file just to get this one site done would be acceptable.