[wp-hackers] How to make root relative urls work in subdomain

Ryann Micua ryannmicua at gmail.com
Mon Oct 31 02:03:30 UTC 2011


I know there is this absolute-vs-relative url debate going on here and 
I've learned quite a bit about the subject and more importantly, about 
the community.

Anyway, this is my problem: I have a testing server, 2 actually - 
http://wp.dev/ (localhost) and http://dev.example.com/ to host my 
project sites

when working on client projects I create a new subdirectory under the 
above domains so that the root to the new development site becomes 
http://wp.dev/projectname/ and http://dev.example.com/projectname/ and 
install wordpress from there. And for people who still don't get what 
I'm trying to do here, to view a page, I access it now through 
http://wp.dev/projectname/about-page/

Now, to link to my assets (css, js, images) I currently do <?php echo 
get_template_directory_uri(); ?>/css/base.css or something like that 
which prints out an absolute url.  Now I have no problem with that or 
with doing that for my wp projects.

My issue is when I have to create non-wp sites like say static pages. 
for linking to assets, I have to spell out the whole url or at least do 
something like
/projectname/css/style.css then, when I need to upload it to the final 
server, i have to change the urls now to /css/style.css

So my question, what do i need to do so that in my pages, all I need to 
write for my url is /css/style.css and it'll work if I put that in 
http://wp.dev/projectname/ and http://dev.example.com/projectname/ and 
on http://www.projectname.com/ or basically no matter where i put it.

-- 
*Ryann Micua*
/Web Developer/
------------------------------------------------------------------------

Website: /www.pogidude.com/
Skype: /rmicua/
Mobile: /+639169273059/



More information about the wp-hackers mailing list