Page 1 of 1

mod_rewrite : exclude folder.... not that obvious

Posted: Tue Feb 20, 2007 11:39 am
by thiscatis
Hello,

Having a problem where that I tried several "solutions" for but neither of them worked.

My htaccess file in the root is:

Code: Select all

RewriteEngine on
RewriteRule ^([A-Za-z]+)$ /$1/ [R]
RewriteRule ^([A-Za-z]+)/$ /index.php?module=$1
But I want to exclude folder from them.
For example the folder
/images/
/admin/
etc...

I tried it with the RewriteCond to exclude those folder names but the problem is that I still want
to use mod rewrite within those folders... If you know what I mean.

For eg: when the user goes to mydomain.com/admin/, instead of the rewrite it actually goes to the mydomain/admin/ folder
but within the admin folder I still use mod rewriting for better urls.

Posted: Tue Feb 20, 2007 11:59 am
by Kieran Huggins
exclude it from the root directory, then have another .htaccess with mod_rewrite rules inside each of the excluded folders.

Posted: Tue Feb 20, 2007 12:20 pm
by thiscatis
I tried that, didn`t worked.

when I did that a URL like mydomain.com/admin/edit/ it just went to mydomain.com/edit/

Posted: Tue Feb 20, 2007 12:22 pm
by Kieran Huggins
exclude the admin directory in the root .htaccess with RewriteCond

then put your admin rewrite rules in a second .htaccess inside the admin directory

Posted: Tue Feb 20, 2007 12:38 pm
by thiscatis
yes, I did that.

.htaccess in root

Code: Select all

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/admin/.*
RewriteRule ^([A-Za-z]+)$ /$1/ [R]
RewriteRule ^([A-Za-z]+)/$ /index.php?module=$1
AddType x-mapp-php5 .php
.htaccess in admin

Code: Select all

RewriteEngine on
RewriteRule ^([A-Za-z]+)$ /$1/ [R]
RewriteRule ^([A-Za-z]+)/$ /index.php?setting=$1
AddType x-mapp-php5 .php
if I go to for example mydomain.com/admin/ : all ok, shows the index.php
if I go to mydomain.com/admin/edit/ it just goes to mydomain.com/edit/

Posted: Tue Feb 20, 2007 12:46 pm
by thiscatis
just noticed,

when I do
mydomain.com/admin/edit/ >> it works

mydomain.com/admin/edit >> just goes toe mydomain.com/edit/
but i thought RewriteRule ^([A-Za-z]+)$ /$1/ [R] solves not adding the slash

Posted: Tue Feb 20, 2007 4:14 pm
by feyd
That's what it did. This thread isn't related to PHP, so moving to Installation.