.htaccess ErrorDocument 404/error.php重定向,但error.php页面css和js不工作
我在我的web根目录中为所有错误添加error.php页面。错误页面由根htaccess规则重定向,该规则重定向良好,但页面css和javascript不工作(未加载) 但是如果我测试为:www.myweb.com/error.php,它的显示格式会很好 我的服务器Apache版本2.2.27和PHP版本5.4.28 我的htaccess重定向规则.htaccess ErrorDocument 404/error.php重定向,但error.php页面css和js不工作,.htaccess,.htaccess,我在我的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 我的完全访问权限 # comp
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
我的完全访问权限
# 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
压缩文本、HTML、JavaScript、CSS和XML
AddOutputFilterByType泄气文本/普通
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE应用程序/xml
AddOutputFilterByType DEFLATE应用程序/xhtml+xml
AddOutputFilterByType DEFLATE应用程序/rss+xml
AddOutputFilterByType DEFLATE应用程序/javascript
AddOutputFilterByType DEFLATE应用程序/x-javascript
#删除浏览器错误
浏览器匹配^Mozilla/4 gzip纯文本/html
浏览器匹配^Mozilla/4\.0[678]无gzip
BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
头附加用户代理
suPHP\u ConfigPath/home/myweb/public\u html/php.ini
#图像、css和javascript文件过期1周
标题集缓存控制“最大年龄=604800,公共”
#删除php#
重新启动发动机
重写基/
#从外部将/dir/file.php重定向到/dir/file
重写cond%{REQUEST_METHOD}!邮递
RewriteCond%{THE_REQUEST}\s/+(.*?/)?(?:索引)?(.*?)\.php[\s?][NC]
重写规则^%1%2[R=302,L,NE]
#将/dir/file内部转发到/dir/file.php
重写cond%{REQUEST_FILENAME}-D
RewriteCond%{DOCUMENT_ROOT}/$1\.php-f[NC]
重写规则^(+?)/?$$1.php[L]
#删除用户配置文件#
选项+以下符号链接-多视图
重新启动发动机
重写基/
RewriteCond%{DOCUMENT\u ROOT}%{REQUEST\u URI}\.php-f[NC]
重写规则^(+?)/?$$1.php[L]
重写cond%{REQUEST_FILENAME}-D
重写规则^([\w-]+)/?$userprofile.php?user=$1[L,QSA]
#重新启动发动机#
重写cond%{http_host}^www.myweb.com[nc]
重写规则^(.*)$http://myweb.com/$1[r=301,北卡罗来纳州]
#重新启动发动机#
重写cond%{HTTP_HOST}^111\.111\.11\.111
重写规则(.*)http://myweb.com/$1[R=301,L]
ErrorDocument 404/error.php
ErrorDocument 500/error.php
#安全访问文件
命令允许,拒绝
全盘否定
#禁用服务器签名#
服务器签名关闭
#修正重写
选项-多视图
如果您的css/js没有加载,可能是因为您使用的是相对路径 您可以使用html标题部分中的
base标记
作为css和js文件的路径。然后可以使用相对路径。e、 g
<base href="http://www.example.com/assets/">
或者,您可以在文件路径前面放置一个/
否则,检查broswer中的元件并检查控制台,以了解其未加载的原因。它给出了一个理由 你说他们不工作是什么意思?他们没有装货吗?它们在你的站点或error.php文件中哪里不起作用?它们没有加载sir。但如果我测试为:myweb.com/error.php,它的显示效果会很好。您的htaccess文件中还有其他规则吗?使用所有htaccess规则更新。