Problems using a directory instead of the root directory

Using a single web hosting account to host multiple sites

Problems using a directory instead of the root directory

Postby frosman » Wed Jan 30, 2008 2:29 pm

Dear friends,
I have several addon domains under the root of my cpanel account (myweb.com) in /home/public_html/

public_html/addon1
public_html/addon2
public_html/subdomain1
etc..

I have created a directory /public_html/dir/ where I want to install the website for myweb.com, so I have added these lines to public_html/.htaccess

-------------
RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/dir%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$ [NC]
RewriteRule ^(.*)$ /dir$1 [QSA,L]
---------------
It doesn't work properly. The homepage appear like "myweb.com/dir" or with two slashes.

My first question is, where is the error? I have made some mods but it is worse than the first time.
My second question is , would it be easier going to the httpd.conf and to modify the directory index of this virtual host? (I have shell access). I am afraid of breaking my cpanel account.

Thanks in advance.

Best regards
Víctor M.
frosman
 
Posts: 2
Joined: Wed Jan 30, 2008 2:12 pm

Postby richardk » Wed Jan 30, 2008 3:55 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/dir%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com$ [NC]
RewriteRule ^(.*)$ /dir/$1 [QSA,L]


My second question is , would it be easier going to the httpd.conf and to modify the directory index of this virtual host?

<VirtualHost>s are better than mod_rewrite. Look into using Name-based Virtual Hosts.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

It works

Postby frosman » Thu Jan 31, 2008 12:34 am

Thanks,
it works properly, and I have understood my error.

About virtualhost, I don't know if there will be any problem modifying manually the httpd.conf, just changing the document root, because these files are controlled by the cPanel/WHM scripts.
frosman
 
Posts: 2
Joined: Wed Jan 30, 2008 2:12 pm

Postby richardk » Thu Jan 31, 2008 3:45 pm

About virtualhost, I don't know if there will be any problem modifying manually the httpd.conf, just changing the document root, because these files are controlled by the cPanel/WHM scripts.

If you want to use <VirtualHost>s you might find the answer on the cPanel forums.
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 18 guests

cron