Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 允许访问.htaccess中的某些目录和文件_Php_Apache_.htaccess_Http - Fatal编程技术网

Php 允许访问.htaccess中的某些目录和文件

Php 允许访问.htaccess中的某些目录和文件,php,apache,.htaccess,http,Php,Apache,.htaccess,Http,我有一个带有MVC和.htaccess文件的php应用程序,它可以重新定义指向index.php文件的所有链接 但是我需要访问其他文件夹和文件,如public/css、public/js、public/images和auther…大多数MVC规则包含以下内容: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f 这是为了防止指向实际文件的URL被重写到mvc。例如,如果您想直接链接到public/css

我有一个带有MVC和.htaccess文件的php应用程序,它可以重新定义指向index.php文件的所有链接
但是我需要访问其他文件夹和文件,如public/css、public/js、public/images和auther…

大多数MVC规则包含以下内容:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
这是为了防止指向实际文件的URL被重写到mvc。例如,如果您想直接链接到
public/css
,而不是
/css
,则需要在MVC规则之前放置一条规则,如下所示:

RewriteCond %{REQUEST_URI} !^/public
RewriteRule ^(css|js|images)/(.*)$ /public/$1/$2 [L]

这将在内部将
/css/some/stylesheet.css
重写为
/public/css/some/stylesheet.css

您应该添加一个允许访问这些目录的条件

# Requested filename does NOT contain index.php, resources, or robots.txt
RewriteCond $1 !^(index\.php|resources|robots\.txt)
# Requested file does NOT exist
RewriteCond %{REQUEST_FILENAME} !-f
# Requested directory does NOT exist
RewriteCond %{REQUEST_FILENAME} !-d
# If all the above rules are true, redirect to index.php/$1
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
请访问