Mod_Rewrite to hide subdirectories

Hey guys, I know you get tired of helping n00bs. I’ve read everything I can find, tried really hard and can’t figure this out.

I am trying to host multiple domains on one lunarpages server. The primary domain is on brainrender.com.

The secondary domain is thediyworkshop.com. It is in the subfolder brainrender.com/diy/ This mod_rewrite I came up with successfully routes it, and it shows “thediyworkshop.com” but then as soon as I click any of the links including “Home” it becomes

thediyworkshop.com/diy/arbitrarypage/

I don’t get it. Technically, that folder shouldn’t exist, (ie brainrender.com/diy/diy) and all it’s doing is rewriting brainrender.com to thediyworkshop.com. What am I doing wrong?

Excerpt:

#DIY WORKSHOP MOD_REWRITE
# Directive to always remove 'www' and/or redirect to correct domain.
RewriteCond %{HTTP_HOST} ^www\\.thediyworkshop\\.com$ [NC]
RewriteRule ^(.*)$ http://thediyworkshop.com/$1 [R=301,L]

# Directive to invisibly redirect to subfolder.
RewriteCond %{HTTP_HOST} ^thediyworkshop.com$
RewriteCond %{REQUEST_URI} !^/diy/
RewriteRule ^(.*)$ /diy/$1

Thanks!
Gordon

Ok, so not bumping this on purpose. I just can’t find any way I’m allowed to edit my post.

The mod_rewrite script is working fine. Sorry, it’s Joomla that’s writing it into my links. The fix was to rename joomlaroot/htaccess.txt to .htaccess (basically enabling it) open it up and change #RewriteBase /" to RewriteBase /joomaroot

Then go into the configuration.php in joomlaroot, and set var $live_site = “http://seconddomain.com

Happily Redirecting! Thanks!
-GB Ward

Hi GB, and WELCOME to SitePoint’s Apache forum!

Thanks for updating and letting members know what problems you had with Joomla and how you resolved them.

Regards,

DK