CodeIgniter Forums
htaccess exclude sub-directory in the url rewriting. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: htaccess exclude sub-directory in the url rewriting. (/showthread.php?tid=9664)



htaccess exclude sub-directory in the url rewriting. - El Forum - 07-03-2008

[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,


htaccess exclude sub-directory in the url rewriting. - El Forum - 07-03-2008

[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


htaccess exclude sub-directory in the url rewriting. - El Forum - 07-03-2008

[eluser]Atas[/eluser]
Thank you.

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


htaccess exclude sub-directory in the url rewriting. - El Forum - 07-03-2008

[eluser]Cristi[/eluser]
You welcome Smile


htaccess exclude sub-directory in the url rewriting. - El Forum - 07-03-2008

[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.


htaccess exclude sub-directory in the url rewriting. - El Forum - 07-04-2008

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


htaccess exclude sub-directory in the url rewriting. - El Forum - 07-04-2008

[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?


htaccess exclude sub-directory in the url rewriting. - El Forum - 07-04-2008

[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.


htaccess exclude sub-directory in the url rewriting. - El Forum - 10-07-2008

[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?


htaccess exclude sub-directory in the url rewriting. - El Forum - 10-07-2008

[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