最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

htaccess - I can access subdirectory, but not files within it

programmeradmin0浏览0评论

I want to first point out that I have tried to solutions listed in this post and in every case it either hasn't worked or hasn't been appropriate for what I'm trying to do. I have tried several different methods from several different sites and I'm unable to find anything that works for me.

I want to link to a zip file for download. The zip file is in a subdirectory in the wordpress root. I put an empty .htaccess file in that subdirectory, and while I can see the directory index by navigating to I can't access any given file within the directory. When I try to access the file at .zip I get a "Page not found" response from wordpress. I also tried adding the following to the .htaccess file in the subdirectory:

<FilesMatch "\.(zip)$">
Allow from All
</FilesMatch>

I also tried adding the following above the # BEGIN WordPress section of the .htaccess file in my root .htaccess as suggested by the question linked above:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/mydirectoryhere/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

Can anyone help me figure out why this is happening? I'm using custom permalinks in my Wordpress installation with the following configuration:

/%category%/%postname%

Here's the contents of my root wordpress installation directory .htaccess file:

# 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

Thank you!

I want to first point out that I have tried to solutions listed in this post and in every case it either hasn't worked or hasn't been appropriate for what I'm trying to do. I have tried several different methods from several different sites and I'm unable to find anything that works for me.

I want to link to a zip file for download. The zip file is in a subdirectory in the wordpress root. I put an empty .htaccess file in that subdirectory, and while I can see the directory index by navigating to http://domain/subdirectory I can't access any given file within the directory. When I try to access the file at http://domain/subdirectory/file.zip I get a "Page not found" response from wordpress. I also tried adding the following to the .htaccess file in the subdirectory:

<FilesMatch "\.(zip)$">
Allow from All
</FilesMatch>

I also tried adding the following above the # BEGIN WordPress section of the .htaccess file in my root .htaccess as suggested by the question linked above:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/mydirectoryhere/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

Can anyone help me figure out why this is happening? I'm using custom permalinks in my Wordpress installation with the following configuration:

/%category%/%postname%

Here's the contents of my root wordpress installation directory .htaccess file:

# 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

Thank you!

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Aug 27, 2015 at 8:12 HendecaHendeca 1367 bronze badges 4
  • 1 Are you sure the file is readable by the server? WordPress shouldn't interfere with any physical files/directories. Can you post the entirety of your .htaccess? – TheDeadMedic Commented Aug 27, 2015 at 9:36
  • A ""Page not found" response from wordpress"? Are you sure it is from WordPress and not from the server itself? Exactly what is the response you see, word for word? – s_ha_dum Commented Aug 27, 2015 at 14:36
  • @s_ha_dum Sorry I realized that was an inaccurate description. I get the Wordpress 404 page for my theme. So it's showing the 404.php file in my Wordpress template. As for the exact .htaccess content, I edited it into the original question. – Hendeca Commented Aug 28, 2015 at 1:37
  • @TheDeadMedic I wanted to add that if you navigate to the directory that contains the zip file, you get an index of the directory. If you right click that .zip file and click "Save Link As..." it downloads as expected. Not sure if this helps – Hendeca Commented Aug 28, 2015 at 1:46
Add a comment  | 

1 Answer 1

Reset to default 0

Turns out the file was the problem, as @TheDeadMedic suspected. The permissions were 640. After changing them to 644, the problem was solved!

Thanks for the help.

发布评论

评论列表(0)

  1. 暂无评论