阿帕奇的RewriteCond%{} REQUEST_FILENAME!-d不工作 [英] Apache RewriteCond %{REQUEST_FILENAME} !-d not working
本文介绍了阿帕奇的RewriteCond%{} REQUEST_FILENAME!-d不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有几个问题,我公司网站。我的同事离开了的.htaccess
文件是这样的:
I have a few problems with our company website. My colleague left the .htaccess
file like this:
# Files in this directory will override the
# controlled equivalent.
# First, set up URL rewriting
Options +FollowSymLinks
RewriteEngine On
# Forbid access to .htaccess files
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^php\.ini$ - [F]
# This Apache mod_rewrite rule checks to see
# if the requested file exists as either a file
# or a directory, if it doesn't then we rewrite
# to the respective controlled location (unless
# we're already there!).
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^.*/_control/.*$
RewriteRule ^(.*)$ _control/$1 [L]
一切工作正常,但大约一个星期前,我们mysite.com/admin和404页开始重定向到托管公司的网站。我进一步调查和好像问题出在最后四行。按照格雷格的答案在这里: http://stackoverflow.com/a/697980/1933380 我把它改为:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^.*/_control/.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ _control/$1 [L]
但它也不起作用。该文件夹结构是这样的:
but it doesn't work either. The folder structure looks like:
我缺少的东西或犯了一个错误?
Am I missing something or making a mistake?
推荐答案
该行的RewriteCond相结合,与逻辑AND,所以它才有意义,如果你有2个重写规则行写他们两次。
The RewriteCond lines are combined with a logical AND, so it only makes sense to write them twice if you have 2 RewriteRule lines.
我想,一定是这样的:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/_control/
RewriteRule ^(.*)$ /_control/$1 [L]
这篇关于阿帕奇的RewriteCond%{} REQUEST_FILENAME!-d不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文