• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
htaccess exclude sub-directory in the url rewriting.

#1
[eluser]Atas[/eluser]
Hello, I have the following .htaccess:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|cgi-bin|assets|blog|sitemap\.xml|export)
RewriteRule ^(.*)$ index.php/$1? [L]

I want to know how to exclude a sub-directory (e.g. "blog/images") in the url rewriting (RewriteCond line). In the .htaccess I can only exclude a directory, if I want to exclude a subdirectory (a directory within a directory) I can't do it.

Any help would be appreciated.
Thanks,

#2
[eluser]Cristi[/eluser]
1. give access on the root to "blog" folder
2. inside blog add another .htaccess file which blocks everything but images folder.

I haven't tested it but it might work!

Regards,
Cristi

#3
[eluser]Atas[/eluser]
Thank you.

I changed the permissions of the image folder to 755 and worked fine...

#4
[eluser]Cristi[/eluser]
You welcome Smile

#5
[eluser]Randy Casburn[/eluser]
@Atas -- please be very careful with 755 directories in your public spaces. Even if you 'think' they are not exposed to uploads. This can be very dangerous for your site.

#6
[eluser]Atas[/eluser]
Then how can I solve mi problem without touching the folder persmissions...

#7
[eluser]Randy Casburn[/eluser]
I'm not an .htaccess expert. They are just regular expressions. What have you tried that has not worked for you?

#8
[eluser]Randy Casburn[/eluser]
it would seem to me that if you negate it just like the others it should work:

Code:
RewriteCond $1 !^(index\.php|cgi-bin|assets|blog|sitemap\.xml|export)
vs.
Code:
RewriteCond $1 !^(index\.php|cgi-bin|assets|blog|blog/images|sitemap\.xml|export)

Try it.

#9
[eluser]Yednotek[/eluser]
I'm kind of running into a similar problem.
My .htaccess looks like this:

Code:
RewriteEngine on
RewriteCond $1 !^(trans\.php|index\.php|images|forum|cgi-bin|cgi-bin/mail\.cgi|css|links|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

I need to access the mail.cgi script in my cgi-bin folder, but I keep getting a 404 page not found error. Any suggestions?

#10
[eluser]Randy Casburn[/eluser]
[quote author="Yednotek" date="1223426133"]I'm kind of running into a similar problem.
My .htaccess looks like this:

Code:
RewriteEngine on
RewriteCond $1 !^(trans\.php|index\.php|images|forum|cgi-bin|cgi-bin/mail\.cgi|css|links|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

I need to access the mail.cgi script in my cgi-bin folder, but I keep getting a 404 page not found error. Any suggestions?[/quote]

Yea...you can't use 'paths' in your RewriteCond above. cgi-bin/mail\.cgi isn't going to work. To do that you'll need to use maps.

My best attempt would have you try...
Code:
RewriteEngine on
RewriteCond $1 !^(trans\.php|index\.php|images|forum|cgi-bin|mail\.cgi|css|links|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]


That should fix you up. But like my previous post said. I'm no expert here.

Randy


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.