Forum Moderators: phranque

Message Too Old, No Replies

Rewrite a sub domain to a directory below document root

Rewrite a sub domain to a directory below document root

         

crolpa

12:06 pm on Dec 3, 2008 (gmt 0)

10+ Year Member



Hey,

I want to rewrite a sub domain to a directory below document root using .htaccess

I dont have access to VirtualHost

This is the effect im trying to get:

Current document root: /home/site/html/
Desired Subdomain root: /home/site/sub/

This is what I have to get ya started!

.htaccess


RewriteEngine On
RewriteBase ../
rewriteCond %{HTTP_HOST} ^(sub)\.domain\.com [NC]
rewriteRule ^(.*)$ /sub/$1 [L]

I know RewriteBase doesnt operate like that but
if it did , oh, it would be to easy!

Thanks

jdMorgan

12:51 am on Dec 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are not going to be able to do that without access to httpd.conf, conf.d, or a similar server config file. If it was allowed by your host then you should fire them immediately, as it would constitute a rather big security problem both for them and for you.

However, you could rewrite to /home/site/html/sub if that would help. I have already posted that code today, so forgive me if I don't repeat it here.

Jim