Support » Fixing WordPress » Blocking file indexing via .htaccess

  • thedesignpeople

    (@thedesignpeople)


    Hi,
    I have a website where the filing system was showing. On investigation I found this code: Options -Indexes
    to add to .htaccess to stop this from occurring. They did not say whereabouts to put it. However, I added it (stupidly I guess) within the WP tags so that it looked like this:

    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    Options -Indexes
    
    # END WordPress

    (and yes for some reason I ignored the top warning!!!)… After a few weeks of having it there, it (the Options -Indexes code) disappeared. I couldn’t work out why but then today I re-read the warning at the top and figured out that it was being overwritten!!! My question is: Does WordPress actually overwrite this code from time to time and if so does anyone have any idea how regularly? If no to the above, is it possible that it could be overwritten automatically by a plugin change or something else?

    Thanks for your help!
    Nic

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey there,

    If you place your “custom” directives outside of any # BEGIN … / # END … comment markers, then WordPress (and plugins) should not overwrite them when they update.

    Thread Starter thedesignpeople

    (@thedesignpeople)

    Hi Euler, thanks very much for the response! Out of curiosity, is there any way to tell how often it gets overwritten? Is it specific to full releases or maintenance updates etc? Is there any way to tell or log of some description? Even though I understand in future I won’t put info between the # BEGIN … / # END – it just would be good to know so i can go back to the client.

    Much appreciated!
    Nic

    Hello,

    It depends. There is no way to say when it’ll happen. Just out of curiosity, when you save your permalinks, it gets overwritten as well.

    Thread Starter thedesignpeople

    (@thedesignpeople)

    Just saw it happen for myself!! Thanks Euler – great to know!

    Have a good weekend,
    Nic

    Thread Starter thedesignpeople

    (@thedesignpeople)

    Hi,

    Does anyone from WordPress or anyone know what date (even just month and year) they started adding the warning to the .htaccess that code would be overwritten? At some point, the code went from:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    TO

    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Thanks in advance!
    Nic

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Blocking file indexing via .htaccess’ is closed to new replies.