Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess停止内部重定向_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

.htaccess停止内部重定向

.htaccess停止内部重定向,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,首先,这是我的目录结构 /localhost/p/ .htaccess /localhost/p/inc/ style.css 我在/localhost/p/.htaccess上有这个代码段 它不允许我访问localhost/p/style.css上的文件,但允许我访问index.php 这是日志 [perdir D:/p/] strip per-dir prefix: D:/p/style.css -> style.css [perdir D:/p/] applying pat

首先,这是我的目录结构

/localhost/p/
  .htaccess
/localhost/p/inc/
  style.css
我在/localhost/p/.htaccess上有这个代码段

它不允许我访问localhost/p/style.css上的文件,但允许我访问index.php

这是日志

[perdir D:/p/] strip per-dir prefix: D:/p/style.css -> style.css
[perdir D:/p/] applying pattern '([^/]+)$' to uri 'style.css'
[perdir D:/p/] RewriteCond: input='D:/p/style.css' pattern='^(.+)/([^/]+)$' => matched
[perdir D:/p/] RewriteCond: input='D:/p/inc/style.css' pattern='-f' => matched
[perdir D:/p/] rewrite 'style.css' -> 'inc/style.css'
[perdir D:/p/] add per-dir prefix: inc/style.css -> D:/p/inc/style.css

// I don't know how to stop the .htaccess here, and just get the file
// instead go with [INTERNAL REDIRECT]

[perdir D:/p/] trying to replace prefix D:/p/ with /p/
strip matching prefix: D:/p/inc/style.css -> inc/style.css
add subst prefix: inc/style.css -> /p/inc/style.css
[perdir D:/p/] internal redirect with /p/inc/style.css [INTERNAL REDIRECT]
[perdir D:/p/] strip per-dir prefix: D:/p/inc/style.css -> inc/style.css
[perdir D:/p/] applying pattern '([^/]+)$' to uri 'inc/style.css'
[perdir D:/p/] RewriteCond: input='D:/p/inc/style.css' pattern='^(.+)/([^/]+)$' => matched
[perdir D:/p/] RewriteCond: input='D:/p/inc/inc/style.css' pattern='-f' => not-matched

// Of course it will never match, it should be D:/p/inc/style.css

...
...
...

谢谢,

使用此“重写条件”允许最多1个内部重定向:

## prevent looping from internal redirects
RewriteCond %{ENV:REDIRECT_STATUS} !200

使用此重写条件可允许不超过1个内部重定向:

## prevent looping from internal redirects
RewriteCond %{ENV:REDIRECT_STATUS} !200

你不能阻止它-这就是它在循环中的工作方式-读这个你不能阻止它-这就是它在循环中的工作方式-读这个顺便说一句,我应该把这行放在哪里?错误的顺序将返回意外的结果,对吗?谢谢把它放在这一行之前:RewriteRule[^/]+$inc/$1[L]顺便说一句,我应该把那一行放在哪里?错误的顺序将返回意外的结果,对吗?谢谢将其放在这行之前:重写规则[^/]+$inc/$1[L]