views:

78

answers:

2

Hi everyone,

Im trying to create a rewrite rule to a different directory, but unfortunatly its not working.

My current rewrite sends everything back to the index.php file unless the first word in the query string is admin. The rewrite rule for 'admin' is to admin.php, but i actually want it to go to /var/www/html/website.com/admin/admin.php (instead of the file in the same directory).

This is current .htaccess file.

RewriteEngine On
RewriteRule ^(.*\/?).*(css|images|js/)+.*$ - [L]
RewriteRule ^\/?admin\/?(.*)$ admin.php?url=$1 [QSA,L]

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

If i change the rewrite rule for admin to use a different directory..

RewriteRule ^\/?admin\/?(.*)$ /var/www/html/website.com/admin/admin.php?url=$1 [QSA,L]

It breaks the site. Any ideas?

Thanks.

A: 

It's actually quite simple, you're using the system path, while web path is needed.

Try the following line:

RewriteRule ^\/?admin\/?(.*)$ /subfolder/admin.php?url=$1 [QSA,L]
St.Woland
my directory is sitting below the web path. The web path is /var/www/html/website.com/web/ and the path im trying to access is /var/www/html/website.com/admin/web/
Bennn
Well, you can't. The only way to do so is create another file, that is accessible through web, and include your non-accessible one. Like this [website.com/web/admin.php]: <?php require_once( '../admin/web/admin.php' ) ;
St.Woland
Thanks for the help. I just made a symbolic link to the directory and added a mod_rewrite in there and that worked.
Bennn
A: 

Try these rules:

RewriteRule ^admin($|/(.*)) admin/admin.php?url=$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php?url=$0 [QSA,L]
Gumbo