Change DocumentRoot without DocumentRoot [solved]

New to mod_rewrite? This is a good place to start.

Change DocumentRoot without DocumentRoot [solved]

Postby mano » Sat Jul 25, 2009 7:27 am

Hi, i have application on server where isnt possible change web server directive DocumentRoot. I need to have set DocumentRoot to another directory than to root one. For example /dir1/dir2. Is it possible to configure it in .htaccess? When user will do request to root directory than i want forward him to /dir1/dir2 withou URL changed.

I tryed this (.htaccess in root directory]:
Code: Select all
RewriteEngine On
RewriteRule .* /dir1/dir2


.htaccess in /dir1/dir2:
Code: Select all
RewriteEngine off


This ofcourse work but url didnt changed. URL was example.com/dir1/dir2, but i need example.com/.

Thanks for every answer and advice.

Solution for my app:
Code: Select all
RewriteEngine On
RewriteBase /public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php/$1
mano
 
Posts: 2
Joined: Sat Jul 25, 2009 7:11 am
Location: czech

Postby richardk » Sat Jul 25, 2009 2:59 pm

To "change" the document root, you can use
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule .* /dir1/dir2%{REQUEST_URI} [QSA,L]

in /.htaccess (nothing in /dir1/dir2/.htaccess).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby mano » Sun Jul 26, 2009 1:27 am

Thanks, thats good solution too.
mano
 
Posts: 2
Joined: Sat Jul 25, 2009 7:11 am
Location: czech


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 31 guests

cron