problem moving htaccess with rules out of root of website

Discuss practical ways rearrange URLs using mod_rewrite.

problem moving htaccess with rules out of root of website

Postby bert » Wed Mar 16, 2005 5:16 am

hello,

I'm having problems with rewrite rules that should only be applied to subfolders in a specific folder...

i've got my site at http://localhost/installdir/

When I put following rules in a .htaccess in the /install/ dir everything works perfectly

Code: Select all
#mod rewrite
RewriteEngine On
Options +FollowSymlinks

#site is at http://localhost/installdir/
RewriteBase /installdir/

#do not rewrite on the foo dir
RewriteCond %{REQUEST_URI} !^/installdir/foo/

#rewrite everything in the document folder to the rewrite download script
RewriteRule ^storage/([^/]+)/document/(.*)$ /installdir/foo/document/rewrite_dl.php?doc_url=/$2&storageDir=$1


This way files are streamed by a php script that checks if the user has the right to download the file.

I'd like to move the .htaccess into /installdir/storage/

The moment I do this rewriting fails :(

What should I change?

Thanks!
B.
bert
 

Postby Caterham » Wed Mar 16, 2005 2:40 pm

#do not rewrite on the foo dir
RewriteCond %{REQUEST_URI} !^/installdir/foo/
Do you've also /installdir/foo/storage/xyz/document in that place? Otherwise the condition was redudandent.

Place a RewriteBase only, if the rule doesn't work.

You're in storage, so strip the part from the pattern

Code: Select all
RewriteEngine On
Options +FollowSymlinks

RewriteRule ^([^/]+)/document/(.*)$ /installdir/foo/document/rewrite_dl.php?doc_url=/$2&storageDir=$1 [L]
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 39 guests

cron