阿帕奇的RewriteCond%{} REQUEST

编程入门 行业动态 更新时间:2024-10-13 04:21:12
本文介绍了阿帕奇的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/admin和404页开始重定向到托管公司的网站。我进一步调查和好像问题出在最后四行。按照格雷格的答案在这里: stackoverflow/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

本文发布于:2023-10-31 13:33:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546233.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阿帕奇   RewriteCond   REQUEST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!