我在网站的后端有一个正在访问问题的应用程序。该站点本身使用.htaccess进行路由,但是我的规则似乎不正确。我基本上是试图将所有不包含目录tools/
或ajax/
的内容路由到index.php
:
DirectoryIndex index.php
Options -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
# the folders mentioned here will be accessible and not rewritten
RewriteCond %{THE_REQUEST} !/(ajax|tools)/
# but rewrite everything else
RewriteRule ^ index.php [L]
# ----------------------------------------------------------------------
# UTF-8 encoding
# ----------------------------------------------------------------------
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8
# Force UTF-8 for a number of file formats
AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
# ----------------------------------------------------------------------
# A little more security
# ----------------------------------------------------------------------
# "-Indexes" will have Apache block users from browsing folders without a
# default document Usually you should leave this activated, because you
# shouldn't allow everybody to surf through every folder on your server (which
# includes rather private places like CMS system folders).
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# Block access to "hidden" directories or files whose names begin with a
# period. This includes directories used by version control systems such as
# Subversion or Git.
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
# Block access to backup and source files. These files may be left by some
# text/html editors and pose a great security danger, when anyone can access
# them.
<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
# prevent access to PHP error log
<Files php_errors.log>
Order allow,deny
Deny from all
Satisfy All
</Files>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 6 hours"
</IfModule>
但是,当尝试在tools目录中运行长时间执行的脚本时,它最终给我一个致命错误,提示无法找到路径./controllers/tools.php,这意味着URI已由路由处理系统本来不应该的。有什么想法吗?
编辑-使用完整的.htaccess更新。
答案 0 :(得分:0)
具有这种方式:
Options -MultiViews
RewriteEngine on
RewriteBase /
# the folders mentioned here will be accessible and not rewritten
RewriteCond %{THE_REQUEST} !/(ajax|tools)/ [NC]
# but rewrite everything else
RewriteRule ^ index.php [L]
THE_REQUEST
变量表示Apache从您的浏览器接收到的原始请求,并且在执行某些重写规则后不会被覆盖。此变量的示例值为GET /index.php?id=123 HTTP/1.1