的.htaccess停止内部重定向 [英] .htaccess stop internal redirect

查看:131
本文介绍了的.htaccess停止内部重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这是我的目录结构

First of all, this is my directory structure

/localhost/p/
  .htaccess
/localhost/p/inc/
  style.css

我有这样的片段在 /localhost/p/.htaccess

Options -MultiViews +FollowSymLinks 
RewriteEngine On
RewriteBase /p/

RewriteCond %{REQUEST_FILENAME} ^(.+)/([^/]+)$
RewriteCond %1/inc/%2 -f
RewriteRule ([^/]+)$ inc/$1 [L]

RewriteRule ^(.+)$ index.php [QSA,L]

它不会让我在本地主机/ P / style.css中访问一个文件,但它会让我获得的index.php

It won't allow me to access a file at localhost/p/style.css but it will let me access 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

...
...
...

谢谢

推荐答案

使用这种的RewriteCond允许不超过1内部重定向:

Use this RewriteCond to allow no more than 1 internal redirection:

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

这篇关于的.htaccess停止内部重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆