Document .. subdirectory

Using a single web hosting account to host multiple sites

Document .. subdirectory

Postby riverboat » Tue Apr 15, 2008 7:21 pm

Hi,



I want to run my cms out of a subdirectory, so I want to go to index.php in www.domain.com/subdir/ when entering www.domain.com in the address bar.

I used code from viewtopic.php?t=4282, so my htaccess looks like this:

Code: Select all
Options +FollowSymLinks
RewriteEngine On

.... 

# Fix missing trailing slashes.
RewriteCond /subdir%{HTTP_HOST} ^(/subdir)(www\.)?maindomain\.net$  [NC]
RewriteCond %{DOCUMENT_ROOT}%1%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# Rewrite:
# maindomain.net/* --> /maindomain/*
RewriteCond /subdir%{HTTP_HOST} ^(/subdir)(www\.)?maindomain\.net$ [NC]
RewriteRule .* %1%{REQUEST_URI} [R=301,L]


When maindomain.net is typed in address bar, maindomain.net/subdir/index.php comes up correctly, which is good, but I don't want the subdirectory to show. What code can I put in htaccess to bring up this page without having the subdir show?

TIA,
riverboat
 
Posts: 1
Joined: Tue Apr 15, 2008 6:14 pm

Postby richardk » Wed Apr 16, 2008 3:27 pm

When maindomain.net is typed in address bar, maindomain.net/subdir/index.php comes up correctly, which is good, but I don't want the subdirectory to show. What code can I put in htaccess to bring up this page without having the subdir show?

Oops, my mistake, replace the last [R=301,L] with [QSA,L] and clear your browser's cache.

and
Add
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$

after
Code: Select all
#  domain4.com/* --> /dom4/*


EDIT - Found http://forum.modrewrite.com/viewtopic.php?t=2670 which worked, sorry I am so green, and a bit too tired last night.

You should have some "add missing trailing slashes" code too or it will exposed the sub directory when you miss one out.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Fix missing trailing slashes.
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$  [NC]
RewriteCond %{DOCUMENT_ROOT}/subdir%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# example.com/* --> /subdir/*
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule .* /subdir%{REQUEST_URI} [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 16 guests

cron