Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 735 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

.htaccess Options -Indexes

Thread title: .htaccess Options -Indexes
Reply    
    Thread tools Search this thread Display Modes  
04-15-2010, 06:24 PM
#1
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old  .htaccess Options -Indexes

I've used the above to prevent directory listings however I want to allow myself access to these directory listings.

Does anyone have a workaround without adding code to each directory I want to view? Like a simple IP hack that allows me to view them all but blocks everyone else?

Reply With Quote
04-15-2010, 06:38 PM
#2
Gaz is offline Gaz
Gaz's Avatar
Status: Request a custom title
Join date: Apr 2007
Location: UK
Expertise: Code & Programming
Software: Coda, TextMate, Sublime 2
 
Posts: 2,097
iTrader: 26 / 100%
 

Gaz will become famous soon enough Gaz will become famous soon enough

Send a message via Skype™ to Gaz

  Old

order deny, allow
deny from all
allow from IP HERE

Reply With Quote
04-15-2010, 07:04 PM
#3
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

I don't think that'll work.

As you can see I don't want to prevent access to my site from anyone, just not allow them to view any open directories. However I want myself to view these open directories.

Reply With Quote
04-15-2010, 07:42 PM
#4
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

I am not aware of any such solution. Your best option would be to write a PHP script to browse the directories and list the contents.

Reply With Quote
04-15-2010, 09:32 PM
#5
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

Hmmph. I'll look into it more and see if I can find a solution without resorting to phps.

Reply With Quote
04-15-2010, 09:51 PM
#6
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

I know you asked for a simple IP hack, but failing that here's a not-so-simple one using mod_rewrite.

Code:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$
RewriteRule /$|^$ - [F,L]
With this, you leave Indexes turned on and the rewriter here looks to see if the requesting IP address is not yours (assuming your IP is 12.34.56.78) and if that is the case, forbids access to urls ending in slash or empty (relative to the directory the .htaccess file is in), in other words where directory listings would be.

Reply With Quote
04-15-2010, 10:40 PM
#7
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 3,164
iTrader: 15 / 86%
 

Dan is an unknown quantity at this point

  Old

Hmmph. That looks promising Salathe. (:

I believe some URLs will end in a slash though.

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed