【发布时间】:2014-11-18 19:26:57
【问题描述】:
我的公司网站有一些问题。我的同事将.htaccess 文件留在了_control 目录中,如下所示:
# Virtual site directory
#
# This script lets us make use of default
# versions of files used in a typical site.
# When a request on the site is made for a file
# that doesn't exist, instead of a 404 we rewrite
# the path to /_control/site/
#
# Any file in the directory this script is in will
# take precedence over this script, so this script
# only comes into play if the file does not exist.
# First, set up URL rewriting
Options +FollowSymLinks
RewriteEngine On
# Add trailing slash for directories
# TODO: fix if site not in root dir (e.g. DEV server)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !.+\.(php|js|css|gif|jpg|jpeg|png)$ [NC]
RewriteCond %{REQUEST_URI} !.*/$
RewriteRule ^(.*)$ /$1/ [L,R=301]
# This Apache mod_rewrite rule checks to see
# if the requested file exists, if it doesn't
# then we rewrite to the respective site location.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^.*/_control/(admin|common).*$
RewriteCond %{REQUEST_FILENAME} !^.*/_control/site/.*$
RewriteRule ^(.*)$ site/$1 [L]
我的应用程序的结构如下:
一切正常,但大约一周前,我们的 mysite.com/admin 和 404 页面开始重定向到托管公司的网站。 DaveG 已经在这里回答了问题的第一部分:https://stackoverflow.com/a/26013322/1933380,我能够让虚拟目录正常工作。我仍然遇到 404 页面的问题。我是否遗漏了什么或犯了错误?
【问题讨论】:
-
我在您的 .htaccess 中没有看到任何
ErrorDocument 404行。此外,您的规则是说任何不存在的文件或目录将其发送到site/$1,所以显然这会影响 404 处理。