views:

34

answers:

1

Hello!

I'd like to make a htaccess file, which can make a good structure for my websites.

My .htaccess is now:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_URI} !/admin
RewriteRule ^(.*)$ index.php?q=$1 [QSA]

(based on Sombat's comment, and about 30 try :P)

And I want to make this, with it:

for every elements but (jpg|jpeg|gif|png|css|js|pl|txt)

if domain.xx/admin redirect to the domain.xx/admin directory and don't make a rewrite at all i mean: let me use domain.xx/admin/index.php?asd=1&asdd=2

else rewrite everything as rule one, to index.php.

Thanks for the help.

+1  A: 

You can just add another RewriteCond directive after the one you have now that will exclude the admin directory.

RewriteCond %{REQUEST_URI} !^/admin/.*

That will prevent your RewriteRule from being applied if the RewriteCond matches your admin path. The order of RewriteCond and RewriteRule directives is important, so be sure to put it before the RewriteRule that you want it to affect.

zombat
You cool. Thanks. Btw your name is almost saturday in hungarian. It's szombat. :)
neduddki
haha, really? Awesome, I never knew that :)
zombat
Yup. Btw it doesn't work. :D
neduddki
Hmm... I tested that rule and it worked on my setup. Try `.*` instead of just `*`, that was a typo on my part, but the rule should still technically work.
zombat
Tried. Still not work :(
neduddki
Finally: just the `RewriteCond %{REQUEST_URI} !admin/` was good for me :/ Thanks for your help. High5 from Hungary :P
neduddki