Do i have to cope? could it be improved? site in sub-folder

Using a single web hosting account to host multiple sites

Do i have to cope? could it be improved? site in sub-folder

Postby Jucks » Fri Aug 14, 2009 6:01 am

Hi everyone, I am a regular reader of this forum, so thought i would ask you guys what you thought of this... I have a website lets say "domain.com" now normally all the public html files would simply be placed inside the public_html folder, but they are not.. because i have add-on domains on the account, i have decided to place the files (e.g. my Joomla CMS files) in a folder called /public_html/domain.com/ and i am rewriting the requests for that domain to that folder (this only applies to the main registered domain name, all of the add-on domains live in their own folders), which works just fine... I am using the following to do that...

Code: Select all
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]

RewriteCond %{REQUEST_URI} !^/domain.com/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /domain.com/$1 [L]

RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
RewriteRule ^(/)?$ domain.com/index.php [L]


Now, everything works fine if i am simply browsing the site, even with Joomlas SEF URL's, but for some reason if i try and access a folder.. lets say /test the URL changes to.. http://domain.com/domain.com/test/ - but, if i add a trailing slash after the folder or directory name like this... http://domain.com/test/ it works just fine! Now this isnt essential, but i would be interested to find out what the issue is.. I think it may have something to do with the following peice of code (which i have been using to add force a www)
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
My first thought was.. OK i need to force a trailing slash, to save people having to do it manually, so i tried a few different readily available methods, and they worked.. some what, but appeared on the end of all my URL's even ones ending in .html, which didnt play well with Joomlas SEF URLs.

Apart from that, I wonder if anyone has experienced something to the following, just thinking.... With the same setup as mentioned above, after moving files from the public_html folder into public_html/domain.com/ I have now had to go through and change any redirect lines in my .htaccess like so... from:
Code: Select all
Redirect 301 /web-design.html /web-design/
to this...
Code: Select all
Rediect 301 /domain.com/web-design.html /web-design/
Otherwise they dont work, even though the .htaccess is inside the /domain.com/ folder.. Is there some sort of way to set the "redirect base" like you can with "rewrite base" ... The setup I am using i basically took from here... http://www.hostmonsterforum.com/showthread.php?t=4533

Let me know what you think, even though there is no major issue, I am keen to find out how to fix it, and learn more about the system! Thanks, fellas, much appreciated.. and hope my post wasnt too confusing :P, J
Jucks
 
Posts: 2
Joined: Fri Aug 14, 2009 5:38 am

Postby richardk » Fri Aug 14, 2009 12:55 pm

Now, everything works fine if i am simply browsing the site, even with Joomlas SEF URL's, but for some reason if i try and access a folder.. lets say /test the URL changes to.. http://domain.com/domain.com/test/ - but, if i add a trailing slash after the folder or directory name like this... http://domain.com/test/ it works just fine! Now this isnt essential, but i would be interested to find out what the issue is..

mod_dir adds the trailing slash and redirects. It doesn't know mod_rewrite has changed the URL so redirects to the internal path not the URL path.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Add missing trailing slashes.
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
# It must be a request to a directory.
RewriteCond %{DOCUMENT_ROOT}/domain.com%{REQUEST_URI}/ -d
# It must not already end in a slash ([^/]$)
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

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


Return to Domain Handling

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron