【问题标题】:RewriteRule - Give access to folderRewriteRule - 授予对文件夹的访问权限
【发布时间】:2016-10-03 18:56:07
【问题描述】:

我使用 RewriteRule 将链接从 ?s=xxx 缩短到 /xxx - 但是我遇到了一些问题,我无法访问某些文件夹中的文件。为了帮助解决这个问题,我在规则中做了一个例外:

RewriteRule ^(inv.*) $1 [L]

这是因为我在“inv”文件夹中有 .pdf 文件。

但问题是我也有一些称为 /invitation 的网站。问题是这个链接给出了 404 错误。

如果我删除上面的行,/invitation 有效 - 但随后我在 /inv/xx.pdf 上收到 404 错误。

如何更改使两者都有效的 RewriteRule。

谢谢。

这是我的整个 .htaccess 文件:

DirectoryIndex i.php index.php index.html
RewriteEngine On
RewriteRule ^robots.txt - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule ^(inv.*) $1 [L]
RewriteRule ^([^/]+)/?$ /?s=$1 [NC,L]
RewriteRule ^(nyhet)/([^/]+)/?$ /?s=$1&n=$2 [NC,L]
RewriteRule ^([^/]+)/([^/]+)/?$ /?s=$1_$2 [NC,L]
ErrorDocument 404 http://www.domain.com/404
ErrorDocument 403 http://www.domain.com/404

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    通过

    禁用报告继续
    Options All -Indexes 
    

    然后修复文件规则

    <Files ~ "([.][^][*])^.*\.">
    order allow,deny
    deny from all
    satisfy all
    </Files>
    

    【讨论】:

      猜你喜欢
      • 2012-07-23
      • 2014-10-14
      • 1970-01-01
      • 2020-07-30
      • 2016-09-01
      • 2019-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多