我在我的网络根目录中添加了一个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
答案 0 :(得分:1)
如果你的css / js没有加载,可能是因为你正在使用相对路径。
您可以使用html head部分中的base tag
作为css和js文件的路径。然后你可以使用相对路径。例如
<base href="http://www.example.com/assets/">
或者您可以在路径前放置/
。
否则检查broswer中的元素并检查控制台以查看它未加载的原因。这给了一个理由。