Part of the EllisLab Network
   
 
htaccess exclude sub-directory in the url rewriting.
Posted: 03 July 2008 02:56 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  03-04-2008

Hello, I have the following .htaccess:

RewriteEngine on
RewriteCond 
$!^(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,

 Signature 

?

Profile
 
 
Posted: 03 July 2008 04:04 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  5
Joined  06-05-2008

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

Profile
 
 
Posted: 03 July 2008 04:50 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  03-04-2008

Thank you.

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

 Signature 

?

Profile
 
 
Posted: 03 July 2008 05:02 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  5
Joined  06-05-2008

You welcome smile

Profile
 
 
Posted: 04 July 2008 01:19 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

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

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 04 July 2008 09:57 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  03-04-2008

Then how can I solve mi problem without touching the folder persmissions…

 Signature 

?

Profile
 
 
Posted: 04 July 2008 10:17 AM   [ Ignore ]   [ # 6 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

I’m not an .htaccess expert.  They are just regular expressions.  What have you tried that has not worked for you?

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 04 July 2008 10:31 AM   [ Ignore ]   [ # 7 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

it would seem to me that if you negate it just like the others it should work:

RewriteCond $!^(index\.php|cgi-bin|assets|blog|sitemap\.xml|export

vs.

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

Try it.

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 07 October 2008 03:35 PM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  34
Joined  05-03-2006

I’m kind of running into a similar problem.
My .htaccess looks like this:

RewriteEngine on
RewriteCond 
$!^(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?

 Signature 

Muzikantenbank.net - A CI-powered Dutch Musicians Website

Profile
 
 
Posted: 07 October 2008 04:51 PM   [ Ignore ]   [ # 9 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007
Yednotek - 07 October 2008 07:35 PM

I’m kind of running into a similar problem.
My .htaccess looks like this:

RewriteEngine on
RewriteCond 
$!^(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?

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…

RewriteEngine on
RewriteCond 
$!^(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

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile