mod_rewrite : exclude folder.... not that obvious

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

mod_rewrite : exclude folder.... not that obvious

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

exclude it from the root directory, then have another .htaccess with mod_rewrite rules inside each of the excluded folders.
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post 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/
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post 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/
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That's what it did. This thread isn't related to PHP, so moving to Installation.
Post Reply