【发布时间】:2015-02-20 01:34:04
【问题描述】:
我在我的 web 根目录中添加了一个 error.php 页面,以显示所有错误。由根 htaccess 规则重定向的错误页面重定向很好,但页面 css 和 javascript 不起作用(不加载)。
但如果我测试为:www.myweb.com/error.php 它的显示格式。
我的服务器 Apache 版本 2.2.27 和 PHP 版本 5.4.28
我的 htaccess 重定向规则
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
我的完整 htaccess
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
suPHP_ConfigPath /home/myweb/public_html/php.ini
# expire 1 week to images, css and javascript files
<FilesMatch ".(swf|ico|css|js)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
#Remove php#
RewriteEngine On
RewriteBase /
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ %1%2 [R=302,L,NE]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
#Remove Userprofile#
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ userprofile.php?user=$1 [L,QSA]
#RewriteEngine on#
rewritecond %{http_host} ^www.myweb.com [nc]
rewriterule ^(.*)$ http://myweb.com/$1 [r=301,nc]
#RewriteEngine on#
RewriteCond %{HTTP_HOST} ^111\.111\.11\.111
RewriteRule (.*) http://myweb.com/$1 [R=301,L]
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
#Disable server signature#
ServerSignature Off
# Fix Rewrite
Options -Multiviews
【问题讨论】:
-
你是什么意思他们不工作?他们没有加载吗?它们在您的站点或 error.php 文件中哪里不起作用?
-
他们没有加载,先生。但如果我测试为:myweb.com/error.php 它的显示效果很好。
-
您的 htaccess 文件中还有其他规则吗?
-
更新所有 htaccess 规则。
标签: .htaccess