我有几个问题,我公司网站。我的同事离开了的.htaccess
文件中的 _control
这样的目录中:
I have a few problems with our company website. My colleague left the .htaccess
file inside the _control
directory like this:
# 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]
我的应用程序的结构是这样的:
The structure of my application looks like:
一切工作正常,但大约一个星期前,我们mysite.com/admin和404页开始重定向到托管公司的网站。 DaveG已经在这里找到答案的问题的第一部分: http://stackoverflow.com/a/26013322/1933380 和我能够得到工作的虚拟目录。我仍然有问题的404页。我缺少的东西或犯了一个错误?
Everything was working OK but about a week ago, our mysite.com/admin and 404 page started redirecting to the hosting company's website. DaveG has already answered first part of the problem here: http://stackoverflow.com/a/26013322/1933380 and I was able to get the virtual directories working. I am still having problems with the 404 page. Am I missing something or making a mistake?
你现在正在做什么,说的是网络服务器来查找所有不存在的另一个文件夹(_control)页和目录。如果你想解决这个本没有给出错字的,不存在的页面等的解决方案,你可以使用:
What you are doing now, is telling the webserver to look for all non-existing pages and directories in another folder (_control). This does not give a solution for typo's, non-existing pages etc. If you want to solve this, you could use:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^.*/_control/(admin|common).*$
RewriteCond %{REQUEST_FILENAME} !^.*/_control/site/.*$
RewriteRule ^(.*)$ site/errhandler.php?file=$1 [L]
和创建一个名为 errhandler.php
文件,该文件显示自定义的404页和(例如)给出了基于数据库搜索或其他可能的替代方案。然后,您可以使用 $ _ GET ['文件']
显示原始文件名。
and make a file called errhandler.php
, which displays a custom 404-page and (for example) give possible alternatives based on a database search or whatever. You could then use $_GET['file']
to display the original filename.